Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Backbone.js 使用木偶对象在木偶中布线—;Can';我做不到_Backbone.js_Routing_Marionette - Fatal编程技术网

Backbone.js 使用木偶对象在木偶中布线—;Can';我做不到

Backbone.js 使用木偶对象在木偶中布线—;Can';我做不到,backbone.js,routing,marionette,Backbone.js,Routing,Marionette,我第一次尝试木偶,对它的路线感到非常困惑 这里是我到目前为止所拥有的:一个主干模型,一个主干集合,一个木偶布局视图,一个木偶集合视图,一对木偶项目视图。视图在木偶对象中连接在一起,如下所示: var Orchestrator = Marionette.Object.extend({ initialize: function(layout) { this.layout = layout; // adding a collection view // showing th

我第一次尝试木偶,对它的路线感到非常困惑

这里是我到目前为止所拥有的:一个主干模型,一个主干集合,一个木偶布局视图,一个木偶集合视图,一对木偶项目视图。视图在木偶对象中连接在一起,如下所示:

var Orchestrator = Marionette.Object.extend({
  initialize: function(layout) {
    this.layout = layout;
    // adding a collection view
    // showing the collection view in the layout view

    // all is honky-dory
  },

  // And here is a test function I want to call when I go to localhost:8080/#test:

  test: function() {
    console.log('HELLOOO!!!');
  }

});
这就是困惑。我正在尝试设置路由器:

var Router = Marionette.AppRouter.extend({
  initialize: function(controller) {
    // the 'controller' is an instance of my Orchestrator object defined above
    this.controller = controller;
    console.log(this.controller.test); // the method shows up correctly
    this.appRoutes = {
      'test': 'test'
    };
  }
});
然后我初始化路由器:
var路由器=新路由器(orchestrator)并启动木偶应用程序

路由器中的
console.log
语句显示1)它正在初始化,2)控制器是正确的木偶对象,3)控制器上有方法
test

但是,当我导航到
localhost:8080/#test
(我的应用程序在
localhost:8080
)时,我没有看到任何证据表明
Orchestrator
对象的
测试方法已被调用-我的“HELLO”消息没有出现在控制台中。控制台中也没有错误


你能告诉我可能是什么问题以及如何解决吗?我一直在搜索文档,但到目前为止还没有找到任何答案

D'oh!忘记调用主干.history.start()。愚蠢的我

有时你只是忘记启动它:)