Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EXTJS Store load callback issue

Tags:

extjs

extjs4.1

I load my store as follows:

store.load({
    params: {
        paramMap
    },
    callback: function(records, options, success) {
        if (success) {
            var form = formPanel.getForm();
            var jsonStr = Ext.JSON.encode(records[0].raw);
            var jsonObj = Ext.JSON.decode(jsonStr);
            form.loadRecord(jsonObj);
        }
    }
});

The thing is I only want this call back to fire the first time the store is loaded. I want to remove it after that so that when I reload or load the store again it doesn't call this callback again.

Any idea, I tried getting the callback in the options config but that doesn't seem to work.

like image 397
b3labs Avatar asked Mar 27 '13 18:03

b3labs


1 Answers

Not exactly sure what the problem is. The callback will only get called when the store is loaded with the callback.

store.load({callback:myCallback});
//callback will be called
store.load();
//callback will not be called

If you want to just do something once you might want to use a listener with single set to true. Listeners instead of callbacks is my preferred way.

store.on('load', onStoreLoad, this, {single:true});

The callback function arguments api is slightly different than a load listener, check the docs to see.

like image 177
pllee Avatar answered Nov 07 '22 07:11

pllee