1
我目前确定我的模型是这样的:名称空间我的骨干机型
var Contact = Backbone.Model.extend({
defaults: {
photo: "img/placeholder.png",
name: "",
address: "",
tel: "",
email: "",
type: ""
}
});
和我的收藏,像这样:
var Directory = Backbone.Collection.extend({
model: Contact
});
然后在我的主app.js文件,我在做什么这来定义我的路线:
var AppRouter = Backbone.Router.extend({
initialize:function() {
$('#header').html(new HeaderView().render().el);
},
routes: {
"filter/:type": "urlFilter"
},
urlFilter: function (type) {
directory.filterType = type;
directory.trigger("change:filterType");
},
});
我得到一个错误,下面的代码告诉我'目录'是未定义的。
directory.filterType = type;
directory.trigger("change:filterType");
在我看来,我的新像这样的收集,this.collection = new Directory(contacts);
我很新的骨干,我不知道如果Im做的事情以正确的顺序,而我没有按收藏当我试图做我的过滤类型和触发器或我有事情完全错误的时候不存在。
我的代码可以在这里看到,http://dan.ms/backbone
任何指针感激地接受。