We can trigger a fcuntiona on the parent view from the child view
For that we have to trigger a backbone event as follow in the child view:
events: {
'click [data-action="save-lookup"]': 'saveChanges'
},
saveChanges: function (e) {
try {
e.preventDefault();
console.log("sruthy", e);
Backbone.Events.trigger('saveChanges:saved', { event: e });
} catch (error) {
console.error(error);
}
},
In the intialize of the parent view ,call save changes function when the event trigger as follow:
//To call save changes function on save button click
Backbone.Events.on('saveChanges:saved', function (data) {
// Execute the function manually with the event parameter
this.saveChangesInventory(data.event);
}, this);