我知道這是更經常以相反的方式進行,但在我的具體使用情況下,我需要有一個型號PostsTimes一起集的引用(另一種型號後)。現在,我想:骨幹:我怎麼可以參考集合從模型
var Posts = Backbone.Collection.extend({
model: Post
});
var posts = new Posts(); // my collection
var PostsTimes = Backbone.Model.extend({
url: "api/times.php",
initialize: function(options){
this.posts = options.posts;
},
test: function(){
console.log(this.posts);
}
});
var poststimes = new PostsTimes({posts: posts});
但this.posts
在PostsTimes
始終保持undefined
。有沒有什麼辦法可以做到這一點,而無需定義全局變量?
是什麼'Tampon.posts'?一些數據或其他收集? – 2012-08-06 15:53:21
@ClaudiuHojda對不起,這是一個錯字。現在解決它。 – 2012-08-06 15:55:36