我刚开始学习Marionette和骨干我得到这个错误我无法弄明白
ReferenceError:未定义userModule var collview = new userModule.collectionUserView({
$(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();
});
如果有人能指出我正确的方向,我会很高兴谢谢你。
答案 0 :(得分:0)
您的模块名称是" usersModule" (复数)但是当你实例化集合视图时,你将它称为" userModule" (单数)。