backbone.js - Unable to remove the elements still the array get cleared -
i fetching info server each 10 sec, in this, getting 3 type of data,
after timeout call, removing existing data, can witness console show array clears, elements still maintain append upon.
how can clear both elements in dom , unbind well..
my close function maintain called, elements not remove dom.
my single view :
singleton.view = backbone.view.extend({ tagname :'article', template0 : function(value){ var label = value === 0 ? "projectname" : value === 1 ? "assignedto" :"projectname"; homecoming _.template("<a href='#'><%= "+label+" %></a>"); }, template1 : _.template($('#boardtemplate').html()), initialize :function(prams){ this.template = this['template'+0](prams.subtempno); }, close:function(){ console.log('clean up') // getting consoled this.unbind();// unbinding this.remove();// removing }, render:function(){ var temp = this.template; this.$el.html(temp(this.model.tojson())); homecoming this; } }); homecoming singleton.view;
in views :
listviewappender:function(item,i){ var listelement = new singleton.view({model:item,tempno:0,subtempno:i,tagname:'li'}); listelement.close(); // whenever phone call new instance removing old stuff.. this.$el.find('.'+this.classitems[i]).append(listelement.render().el); },
how can prepare issue.. right approach pelase..
ok quick rework.....you're going have test out. comment happens , i'll right code below.
can try
listviewset:function(key,i){ var l = this.listcatch.length; if(l > 0){ (var = 0; < l; i++) { console.log(this.listcatch[i]); this.listcatch[i].remove(); } } this.listcatch = []; _.each(this.listcollection.models, function(model){ that.listviewappender(model,i); //setting agian. }); }, listviewappender:function(item,i){ var listelement = new singleton.view({model:item,tempno:0,subtempno:i,tagname:'li'}); console.log(listelement); this.$el.find('.'+this.classitems[i]).append(listelement.render().el); this.listcatch[i] = listelement; },
backbone.js backbone-views
No comments:
Post a Comment