-
9 Jun 2012 12:15 PM #1
Ext.AbstractManager.onAvailable listener isn't removed properly
Ext.AbstractManager.onAvailable listener isn't removed properly
REQUIRED INFORMATION
Ext version tested:
- Ext 4.1
Browser versions tested against:
- Google Chrome 19
DOCTYPE tested against:
- <!DOCTYPE html>
Description:
- onAvailable function in class Ext.AbstractManager fails, because not the proper function will be removed after component being available.
Steps to reproduce the problem:
- Create onAvailable listener on component with id 'test'.
- Create the component with id 'test'.
- Function registered will fire once.
- Destroy the component.
- Add onAvailable listener on component with id 'test' again.
- Create the component again with id 'test'.
- Function will be fired twice...
The result that was expected:
- Callback should fire only one, once the component is available with the specified id.
The result that occurs instead:
- Function called as many times as onAvailable listener applied, even if the component was destroyed, then created again between each listener apply.
Test Case:
Code:Ext.ComponentManager.onAvailable('test', function() { alert('I am available, first!'); }); var component = Ext.create('Ext.Component', { id: 'test' }); component.destroy(); Ext.ComponentManager.onAvailable('test', function() { alert('I am available, second!'); }); Ext.create('Ext.Component', { id: 'test' });
HELPFUL INFORMATION
Screenshot or Video:
- none
See this URL for live test case: http://jsfiddle.net/fNnzF/3/
Debugging already done:
- yes
Possible fix:
Additional CSS used:Code: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); } }
- only default ext-all.css
Operating System:
- Windows 7
-
10 Jun 2012 7:23 AM #2
Thank you for the report!
Regards,
Scott.
-
24 Jul 2012 2:11 PM #3
This fix introduced new bug
Try to add two 'onAvailable' listeners
In this case, we will get an exception because event is removed during event firingCode:Ext.ComponentManager.onAvailable('test1', function() { alert('I am available, first!'); }); Ext.ComponentManager.onAvailable('test2', function() { alert('I am available, second!'); }); var component = Ext.create('Ext.Component', { id: 'test1' });
Success! Looks like we've fixed this one. According to our records the fix was applied for
EXTJSIV-6484
in
4.1.


Reply With Quote