0

Backbone.Marionetteを使用して新しいアプリケーションを作成し、Expressアプリを実行してページをロードすると、コンソールでエラーが発生します。

Uncaught TypeError: Cannot read property 'EventAggregator' of undefined 
backbone.marionette.js:1504

それが実際のmarionetteライブラリにあることを示しています。私はその行を見てきました:

Marionette.EventAggregator = Backbone.Wreqr.EventAggregator;

wreqrそして、それは私が追加しなければならない追加のライブラリかもしれないと思っていますか?

アプリを作成するコードは次のとおりです。

require([
    'jquery', 
    'underscore', 
    'backbone', 
    'marionette'
], function( $, _, Backbone, Marionette ){
    MyApp = new Backbone.Marionette.Application();

    MyApp.addRegions({
        main_region: '#main_region'
    });

    MyApp.addInitializer( function(options) {
        var login_form_view = new LoginFormView();
    });
});

ライブラリの場所を設定するrequireconfig:

// using RequireJS 1.0.7
    require.config({
        paths: {
            '$': 'libs/jquery-1.8.2-min',
            'underscore': 'libs/underscore-min', // AMD support
            'backbone': 'libs/backbone.min', // AMD support
            'bootstrap' : 'libs/bootstrap.min',
            'marionette' : 'libs/backbone.marionette', 
            'wreqr' : 'libs/backbone.wreqr',
            'templates': '../templates',
            'text': 'libs/require/text', 
            'login': 'views/user/login'
        }
    });

エラーの原因を知っている人はいますか?

4

1 に答える 1

2

はい、wreqrはMarionetteへの依存関係です。

Wreqrへのパスを指定しましたが、それもロードする必要があります。マリオネットをロードする前に。

require([
     'jquery', 
     'underscore', 
     'backbone', 
     'wreqr',
     'marionette'
], function( $, _, Backbone, Marionette ){
MyApp = new Backbone.Marionette.Application();

MyApp.addRegions({
    main_region: '#main_region'
});

MyApp.addInitializer( function(options) {
    var login_form_view = new LoginFormView();
});

});

于 2012-10-15T18:44:01.600 に答える