我想包括应用程序实例来使用它的事件聚合器显示在这里
当我在视图中包含实例时出现错误.
从App.Bootloader.js中的Requirejs配置文件中解决问题:
require(['App'], function (App){
App.start();
});
Run Code Online (Sandbox Code Playgroud)
来自App.js:
define(function (require){
//...requisite includes $, _, Backbone, Marionette ...
var Layout = require('Layout');
var App = new Marionette.Application();
App.addRegions({
main: '#view_content'
});
App.addInitializer(function (){
App.main.show(new Layout());
//... adding router etc ...
Backbone.Marionette.TemplateCache.loadTemplate = function (template, callback){
callback.call(this, Handlebars.compile(template));
};
Backbone.history.start();
});
return App;
});
Run Code Online (Sandbox Code Playgroud)
来自Layout.js:
define(function(require){
var View = require('folder/folder/View');
//template contains #sub div
var template = require('text!template.html');
return Marionette.Layout.extend({
template: template,
regions: {
sub: '#sub'
},
initialize: function(){
//wait …Run Code Online (Sandbox Code Playgroud)