新的牵线木偶,路由器和控制器配置

Mic*_*969 3 marionette

我一直在看各种木偶问题而没有找到我追求的东西,并希望有人可以给我一些合理的建议和几个指针.我是新手,只是希望在我在github上选择的样板启动包上构建

https://github.com/coombsj/RequireJS-BackboneJs-MarionetteJS-Bootstrap_Starter

我想建立两件事;

  1. 如何为参考项目创建路由和控制器配置 - 请参阅下面解释的示例.
  2. 如何使用相同的引用项目如何在模板页面中包含或使用jquery,诸如页面文档之类的任何内容都可以显示警告框?

它有一个导航结构和我得到的几个区域,但除了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)

在此先感谢您的帮助.麦克风

Dav*_*ulc 8

以下是您在木偶之旅中开始的一些资源:

这些应该让你走上正确的道路.

更多信息:

你究竟遇到什么问题?