PDA

View Full Version : Registering and Invoking onAvailable function



extjs.mscit
25 Oct 2013, 5:14 AM
In extjs 3.4, I have used following to register function. Here, id is field' unique id.



Ext.lib.Event.onAvailable(id,
function(page) {
page.showMyTableState(dataAvailable);
},
this
);

What is the alternate of "Ext.lib.Event.onAvailable" in Extjs 4.1

I tried below, but does not help.

Ext.AbstractManager.onAvailable(id,


Thanks.

mitchellsimoens
28 Oct 2013, 12:44 PM
You souldn't use the AbstractManager, you should use a subclass like the ComponentManager

extjs.mscit
29 Oct 2013, 2:56 AM
Can you please provide me any examples. If I register a function using below method, It never invoke [showMyTableState] method.


Ext.ComponentMgr.onAvailable(id,
function(page) {
page.showMyTableState(recProgData.DAYSOFWEEK);
},
this
);

evant
29 Oct 2013, 3:05 AM
Then it means your component never becomes available. Here's a trivial test case:



Ext.require('*');

Ext.onReady(function() {

new Ext.Component({
id: 'a'
});

Ext.ComponentManager.onAvailable('a', function() {
console.log('already loaded, fire straight away');
});


Ext.ComponentManager.onAvailable('b', function() {
console.log('not loaded, fire when ready');
});

new Ext.Component({
id: 'b'
});

});

extjs.mscit
29 Oct 2013, 8:27 AM
Thanks, I understand.
Can I attach onAvailable event on table, as below??
It does not invoke the method, Is that because I am registering method to HTML table tag and not to panel??



var id = Ext.id();
var HTML = "<table id=" + id+ " class=\"t-grid-inline-days\"><tbody><tr>";
var td = "<td class=\"t-grid-day-off";
HTML = HTML + td + "\">" + this.it.myName[0].substring(0,2) + "</td>";
HTML = HTML + td + "\">" + this.it.myName[1].substring(0,2) + "</td>";
HTML = HTML + "<\/tr></tbody><\/table>";

Ext.AbstractManager.onAvailable(id,
function(page) {
page.showMyTableState(recProgData.DAYSOFWEEK);
},
this
);

Thanks.

evant
29 Oct 2013, 12:53 PM
No, you can't. There's nothing that tracks when the HTML state of the page changes. You'd need to call whatever function after you create it.