我有一个集合,我填充了现有数组的元素。视图正在侦听集合添加事件。每次我向集合添加内容时都会呈现。
collection.add(_collection); //_collection = array of model objects
// collection = backbone collection
这是我的观点的渲染和初始化:
initialize: function(options){
this.el = options.el;
fbsCollection.update(this.attributes.folder);
this.collection = fbsCollection.collection;
this.collection.on("add", this.render, this);
},
render: function() {
localStorage.state
localStorage.state = 2;
if(fbsCollection.folder.get("folder")!="")
document.getElementById('preFolderButton').style.display = 'block';
else
document.getElementById('preFolderButton').style.display = 'none';
this.$el.empty();
var temp = _.template(aftemp, {boxFolder: this.collection, folder : fbsCollection.folder});
this.$el.html(temp);
created = true;
$("#boxBrowserContent").trigger("create");
},
该数组包含20个元素。直到最后一个元素被添加到10年后的backbone.collection中。
我最近从phonegap 3.0.0更新到3.3.0。这产生了一些不好的影响,我担心这也与更新有关。