It was worked well with previous version of marionette
. Now I updated to 2.2 newer version. But I am not able to hear my trigger now.
i understand it is updated and changed the approach. any one guide me to get the new approach please?
my trigger in itemView :
List.Contact = Marionette.ItemView.extend({
tagName : "tr",
events: {
"click": "highlightName"
},
triggers : {
"click button.js-delete" : "contact:delete" // i trigger delete from here
},
template : "#contact-list-item",
highlightName: function (e){
e.preventDefault();
this.$el.toggleClass("warning");
},
remove : function () {
var self = this;
this.$el.fadeOut('slow', function() {
Marionette.ItemView.prototype.remove.call(self);
});
}
});
Here is i am trying to hear my trigger: (controller)
List.Controller = {
listContacts : function () {
var contacts = ContactManager.request("contact:entities");
var contactsListView = new List.Contacts({
collection : contacts
});
contactsListView.on("itemview:contact:delete", function (childView, Model) {
console.log("i am hearing!"); //not working at all...
contacts.remove(model); //is the way is wrong?
});
ContactManager.mainRegion.show(contactsListView);
}
}
Both are nested with separate modules. please help me. Thanks in advance!
I updated itemview
- in to childview
- it's works fine.
List.Controller = {
listContacts : function () {
var contacts = ContactManager.request("contact:entities");
var contactsListView = new List.Contacts({
collection : contacts
});
contactsListView.on("childview:contact:delete", function (childView, Model) {
console.log("i am hearing!"); //not working at all...
contacts.remove(model); //is the way is wrong?
});
ContactManager.mainRegion.show(contactsListView);
}
}