PDA

View Full Version : Extjs 4.2.1: SYNC callback or similar... best practice



arnoldvillasanta
22 May 2014, 9:48 PM
Hi,

I call store.sync() in the controller.

I want to store.load() every time there's an update/create at the backend, specifically to get the backend-generated ID of the created record as well as to fetch the actual data saved in the database on field updates.

What's the best way to do this?
(Making sure that the back-end save/update was executed before calling the store.load()).
Expected sequence should be: store.sync >>> update/create in backend >>> callback >>> store.load


Thanks in advance.

arnoldvillasanta
23 May 2014, 3:35 AM
This is what I'm using now:

store.sync({
success: function(batch) {
console.log('The STORE was sync');
store.load();
}
});

undeclared
29 May 2014, 1:58 PM
Just add a 'write' event, that's after sync.

Most basic way of doing that is:
store.on('write', function(store) { store.load(); });

Also I do wonder if there's a better way to send event listeners to stores that are part of something else besides getting the store instance from the object itself..