简体   繁体   中英

Marionette Module error

i just start learning Marionette and backbone i am getting this error i cant figure out

error

ReferenceError: userModule is not defined var collview = new userModule.collectionUserView({

code

$(function () {

    MyApp = new Backbone.Marionette.Application();

    MyApp.addRegions({
        mainRegion: "#content"
    });

    MyApp.module("usersModule", function(usersModule, MyApp, Backbone, Marionette, $, _){

        usersModule.singleModel = Backbone.Model.extend({});

        userCollection = Backbone.Collection.extend({
            model: usersModule.singleModel
        });

        usersModule.singleview = Backbone.Marionette.ItemView.extend({
            template: "#userlist",
            tagName: "tr",
            className: "cls-user-details"
        });

        usersModule.collectionUserView = Backbone.Marionette.CollectionView.extend({
            tagName: "table",
            id: "usertable-view",
            className: "user-record",
            template: "#usertable",
            itemView: usersModule.singleview,
            appendHtml: function (collectionView, itemView) {
                CollectionView.$('tbody').append(itemView.el);
            }
        });

        usersModule.addInitializer( function (options) {

            var collview = new userModule.collectionUserView({
                collection: data.d
            });

            MyApp.mainRegion.show(collview);

        });
    });

    MyApp.start();
});

i be would glad if someone can point me to the right direction thanks you.

您的模块名称为“ usersModule”(复数),但是当实例化集合视图时,您将其称为“ userModule”(单数)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM