【发布时间】:2014-09-10 00:16:50
【问题描述】:
我正在尝试在我的骨干网中设置路由。Marionette 应用程序,我是 Backbone 的新手。
我有 JS 喜欢
var firstProject= new Marionette.Application();
firstProject.addRegions({
main : 'main',
});
//my router
var MyRouter = Backbone.Marionette.AppRouter.extend({
// "someMethod" must exist at controller.someMethod
appRoutes: {
"first" : "someOtherMethod"
},
/* standard routes can be mixed with appRoutes/Controllers above */
routes : {
"second" : "someOtherMethod"
},
someOtherMethod : function(){
alert('hi')
}
});
firstProject.on('initialize:after', function(){
if(Backbone.history){
Backbone.history.start();
}
});
在我的 html 中,我有
<a href="#/first" class="btn btn-primary btn-lg" role="button">First product</a>
<a href="#/second" class="btn btn-primary btn-lg" role="button">First product</a>
当我单击链接时,我想浏览我的页面以加载我的第一个 html 页面和第二个 html 页面。我已经阅读了文档,但它们有点复杂。有人可以给我一个提示吗?非常感谢!
【问题讨论】:
-
尝试将/从
href中取出。只需使用#first和#second -
你确定你的主要区域选择器是
main你的意思是.main还是#main?
标签: html backbone.js marionette