我一直在看各种木偶问题而没有找到我追求的东西,并希望有人可以给我一些合理的建议和几个指针.我是新手,只是希望在我在github上选择的样板启动包上构建
https://github.com/coombsj/RequireJS-BackboneJs-MarionetteJS-Bootstrap_Starter
我想建立两件事;
它有一个导航结构和我得到的几个区域,但除了LandingView.html之外,导航不会加载contentRegion中的任何页面.
这似乎是现在模板页面创建(手柄),我很好,但他们正在努力正确创建路由和控制器部分.
目前,Router.js看起来像这样
define(['marionette', 'app/Controller'],
function (marionette, Controller) {
'use strict';
return marionette.AppRouter.extend({
appRoutes: {
'test' : 'testView',
'*action' : 'logAction'
},
controller: Controller
});
});
Run Code Online (Sandbox Code Playgroud)
和Controller.js
define(['app/views/LandingView'],
function (LandingView) {
"use strict";
return {
logAction: function (action) {
console.log(action);
S2C.content.show(new LandingView());
}
};
});
define(['app/views/testView'],
function (testView) {
"use strict";
return {
testView: function (test) {
console.log(action);
S2C.content.show(new testView());
}
};
});
Run Code Online (Sandbox Code Playgroud)
LandingPage加载正常
LandingView.js
define(['marionette', 'tpl!app/views/_templates/LandingView.html'],
function (Marionette, template) {
"use strict";
return Marionette.ItemView.extend({
template: template()
});
});
Run Code Online (Sandbox Code Playgroud)
LandingView.html
<div style="background-color:#6CF">
<h2>
This is the home page
</h2>
</div>
Run Code Online (Sandbox Code Playgroud)
我的testView没有加载
testView.js
define(['marionette', 'tpl!app/views/_templates/testView.html'],
function (Marionette, template) {
"use strict";
return Marionette.ItemView.extend({
template: template()
});
});
Run Code Online (Sandbox Code Playgroud)
testView.html
<form class="form-inline" id="testForm" method="post" action="#">
<div>
<input type="text" name="name" accesskey="s" size="30"
value=""/>
<input type="submit" value="Find"/>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助.麦克风
以下是您在木偶之旅中开始的一些资源:
这些应该让你走上正确的道路.
更多信息:
event对象中声明将启动警报(或运行一些jQuery代码)的处理程序,请参阅https://github.com/davidsulc/marionette-gentle-introduction/commit/d63ccd041aba74e972c0fa93264c45c47e6f2e6e你究竟遇到什么问题?
| 归档时间: |
|
| 查看次数: |
8055 次 |
| 最近记录: |