PDA

View Full Version : IE8/9 are not in time when destroy/add components



lfs2008
6 Aug 2014, 5:46 AM
i have an issue with IE8/9 while adding some components.
if i do not do small defer between creating component and insertion to panel, it just never added.

funny enough, i can do simple console.log instead of defer - it will do.

could someone please give me a clue - what is not correct in my code snippet



Ext.define('MyPanel', {
requires: [
'MyStore',
'AnalyzeRowPartBottom'
],
initComponent: function (options) {
var store = Ext.create('MyStore', {
listeners: {
load: function (store, records, successful, operation) {


if (me.AnalyzeRowPartBottom){
me.remove(me.AnalyzeRowPartBottom);
me.AnalyzeRowPartBottom.destroy();
}


me.AnalyzeRowPartBottom = Ext.create('AnalyzeRowPartBottom', {
store: me.storeOptimised
});


var deferTime = Ext.isIE9m (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext-property-isIE9m) ? 10 : 0;

//i have to do this trick
//defer or console.log(me);

Ext.Function.defer(function(){
me.add(me.AnalyzeRowPartBottom);
me.setLoading(false);
me.doLayout();
}, deferTime);

}
}
});

store.load();
me.callParent(arguments);
}

});

fmoseley
15 Aug 2014, 3:06 PM
Could be a timing issue. Store loads are asynchronous rather than add the component based on the load listener try using the store.load callback. (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Store-method-load)

lfs2008
18 Aug 2014, 12:52 AM
how load listener is different vs store.load (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Store-method-load)

fmoseley
18 Aug 2014, 4:22 PM
Though the listener event should only fire after the store has loaded its safer to use the callback.

lfs2008
19 Aug 2014, 3:01 AM
why

fmoseley
19 Aug 2014, 12:05 PM
Callback only executed after store.load is complete.

lfs2008
19 Aug 2014, 1:04 PM
and when load event fired?