javascript - backbone - preventing same view from overlapping -


let each row in table got own view , model (collectionviews). each row got button editing row data. when clicked editview activated current row , model form presented user textfield , cancel , submit button.

enter image description here

the edit view can removed if user submit edit form or cancel edit.

my question best way prevent multiple edit view overlapping example when user click edit button, not doing editing or closing edit view, , instead click edit button on row , row, without completing editing.

i started learning backbone, - more of hack.

//create global array storing view var edittaskviewarray = new array(); 

code when creating edit view

//delete previous view (x in edittaskviewarray) {    edittaskviewarray[x].remove(); }  //empty array edittaskviewarray = [];  //create , activate edit view var edittaskview = new app.views.edittask({     model: this.model  }).render(); $('#edittask').append(edittaskview.el).hide().fadein(500);  //add edit view array can removed later edittaskviewarray.push(edittaskview); 

thank tips

//change delete code to.

//edittaskview global //delete previous view if 1 exists  if(edittaskview.el){     edittaskview.remove(); }  //create , activate edit view edittaskview = new app.views.edittask({model:this.model }).render();  $('#edittaskview').append(edittaskview.el).hide().fadein(500); 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -