I working with my model and modal which is common for all models, I wonder what is the proper approach in handling the id of deleting model, my idea was:
on delete link trigger the function in model:
modal : function(e) {
var edu_id = $(e.currentTarget).data('id'),
confirm = $(e.currentTarget).data('confirm');
newModal = new Modal({ model: new Backbone.Model({header:"Potwierdź", content: confirm}) });
// we are waiting for OK button in modal, when event occured FIRE!
newModal.on('fire',this.fire,this);
e.preventDefault();
}
I'm listening for the event 'fire' which i triggering when user clicked on OK button, the main issue is how could I pass the edu_id for deleting element? Is that generally good approach or I should make it in different way.
Answer to myself ;), how I did it is just trigger event in child event with additional param:
this.trigger('fire',model_id);
and it works fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.