Reputation: 4912
How to fire the update
event on a store manually, by clicking a button or a link?
I'm trying this:
var someStore = Ext.getCmp('someGrid').getStore();
//Save yes is a hyperlink I inserted in the DOM.
Ext.get('save-yes').on('click', function(e){
e.preventDefault();
someStore.fireEvent('update');
});
someStore.on('update', function(){
console.log('Updating');
});
The click works, but the store's event is not triggered.
Upvotes: 2
Views: 3382
Reputation: 5856
Never fire events this way. The library events are fired when something happens that needs to be handled so firing update event when data has not changed does not make any sense. Event listener is expected to handle changes so it does not need to run when there is no change.
Further, events must be fired with some signature so you need to grab data that original fireEvent uses that can be problematic very often.
Last, but probably most important, once you have a function that serves as the listener you do not need to artificially fire the event for the function to run. You can just call the function.
Upvotes: 1