首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >marionette todomvc扩展错误

marionette todomvc扩展错误
EN

Stack Overflow用户
提问于 2013-02-11 11:02:34
回答 1查看 341关注 0票数 0
代码语言:javascript
复制
TodoMVC.module "TodoList", (TodoList, App, Backbone, Marionette, $, _) ->

  # TodoList Router
  # ---------------
  #
  # Handle routes to show the active vs complete todo items
  TodoList.Router = Marionette.AppRouter.extend
    appRoutes: "*filter": "filterItems"

  # TodoList Controller (Mediator)
  # ------------------------------
  #
  # Control the workflow and logic that exists at the application
  # level, above the implementation detail of views and models
  TodoList.Controller = ->
    @todoList = new App.Todos.TodoList()

  _.extend TodoList.Controller::,

    # Start the app by showing the appropriate views
    # and fetching the list of todo items, if there are any
    start: ->
      @showHeader @todoList
      @showFooter @todoList
      @showTodoList @todoList
      App.bindTo @todoList, "reset add remove", @toggleFooter, this
      @todoList.fetch()

    showHeader: (todoList) ->
      header = new App.Layout.Header(collection: todoList)
      App.header.show header

    showFooter: (todoList) ->
      footer = new App.Layout.Footer(collection: todoList)
      App.footer.show footer

    showTodoList: (todoList) ->
      App.main.show new TodoList.Views.ListView(collection: todoList)

    toggleFooter: ->
      App.footer.$el.toggle @todoList.length

    # Set the filter to show complete or all items
    filterItems: (filter) ->
      App.vent.trigger "todoList:filter", filter.trim() or ""


  # TodoList Initializer
  # --------------------
  #
  # Get the TodoList up and running by initializing the mediator
  # when the the application is started, pulling in all of the
  # existing Todo items and displaying them.
  TodoList.addInitializer ->
    controller = new TodoList.Controller()
    new TodoList.Router(controller: controller)
    controller.start()

未捕获NoMethodError:在控制器上找不到方法'filterItems‘

我使用了TodoMVC example for Marionette,并使用js2coffee将其转换为CoffeeScript,我使用的是requirejs。我不确定为什么会发生这种情况,因为我没有添加真正的自定义代码。如果我能提供任何其他信息,请让我知道。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-07 00:48:25

我也有这个错误。

问题出现在以下代码中:

代码语言:javascript
复制
TodoList.Controller = ->
    @todoList = new App.Todos.TodoList()

一旦转换为JS,它将在第二行前面添加return。对我来说,添加true作为下一行就解决了这个问题。

代码语言:javascript
复制
TodoList.Controller = ->
    @todoList = new App.Todos.TodoList()
    true
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14805288

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档