What I am trying
On Save or Delete of my form a simple notification is poped-up to user
What I have done
events :{
'#save-button click' : 'onSaveBUttonClick',
'#delete-button click' : 'onDeleteButtonClick'
};
onDeleteButtonClick = function(){
//popup appears to confirm delete
this.model.on('sync',function(model){
model.off('sync');
alert("project deleted");
},this);
this.model.destroy();
}
onSaveBUttonClick = function(){
//popup appears to confirm delete
this.model.on('sync',function(){
model.off('sync');
alert("project Saved");
},this);
this.model.save();
}
The problem
I click on the delete button and say , select , cancel. Here the model.on('sync') is bound to the model.
Now when I click save , and confirm , the model.on('sync') is called twice (one bound by delete button and one bound by save button).
So I am getting 2 pop-ups Project deleted first and project saved after it.
How can I avoid this?
You can use the success options in
model.saveandmodel.destroyYour methods could look like