Reputation: 993
I have an Ext.Data.Store. And i have a function, that need to invoke one time, when store is loaded. Only one time. At first i did this:
function invokeMe() {
alert("!");
}
actionTemplateStore.on('load', function () {
invokeMe();
}
But one problem isin this solution: I really need once invoce "invokeMe"-function
Upvotes: 2
Views: 109
Reputation: 1575
actionTemplateStore.on('load', function () {
if (!actionTemplateStore.actionInvoked) {
invokeMe();
actionTemplateStore.actionInvoked = true;
}
}
Update: as Lloyd mentioned, you can also use {single:true} option.
actionTemplateStore.on('load', yourFunction, {single:true});
Upvotes: 1
Reputation: 29668
Try this:
function invokeMe() {
alert("!");
}
actionTemplateStore.on('load',function () {
invokeMe();
},this,{single: true});
We pass in this
for the scope and a config object with single: true
which causes it to execute only once.
You could also do this:
var onLoad = function(store) {
alert('!');
store.un('load',onLoad);
}
actionTemplateStore.on('load',onLoad);
Upvotes: 0