PDA

View Full Version : [FIXED]Ext.ComponentMgr.onAvailable never fires callback



blakel
1 Mar 2011, 12:47 PM
Here is the code I am using:


<html>
<head>
<title></title>

<script type="text/javascript" src="bootstrap.js"></script>

<script type="text/javascript">
Ext.onReady(function() {
var id = "anID";
Ext.ComponentMgr.onAvailable(id, function() { alert('now available'); });
new Ext.Panel({
items: [{
id: id,
xtype: 'textfield'
}]
}).render(Ext.getBody());
});
</script>
</head>
<body></body>
</html>


This works correctly in 3.3. In 4.0 the callback is never fired.

Tested in FF 3.6.13, Chrome 9.0.597.98 and IE 9.0.8080.16413.

evant
2 Mar 2011, 12:28 AM
This has been resolved, thanks.

attila.huszko
8 Jun 2012, 10:28 AM
Hi guys, onAvailable function in the class Ext.AbstractManager fails, because it is remove not the proper function from the listener after event fired.

4.1 original:


onAvailable : function (id, fn, scope) {
var all = this.all,
item;
if (all.containsKey(id)) {
item = all.get(id);
fn.call(scope || item, item);
} else {
all.on('add', function (map, key, item) {
if (key == id) {
fn.call(scope || item, item);
all.un('add', fn, scope);
}
});
}
}


Fix:


onAvailable : function (id, callback, scope) {
var all = this.all,
item,
fn;
if (all.containsKey(id)) {
item = all.get(id);
callback.call(scope || item, item);
} else {
fn = function (map, key, item) {
if (key == id) {
callback.call(scope || item, item);
all.un('add', fn);
}
};
all.on('add', fn);
}
}


Attila