-
1 Feb 2012 3:17 AM #1
Unanswered: Same ID Component Bug
Unanswered: Same ID Component Bug
I think what I found seems a PR4 bug but would like to confirm if it persist at your side too.
I created a panel under a view like this.
I remove all components and then add this to the view.Code:var video = Ext.create('Ext.Panel', { id : 'jwPlayerContainer', html : '<object type="application/x-shockwave-flash" id="jwplayer" name="jwplayer" data="jwplayer/player.swf" width="480" height="270" style="width: 1286px !important; height: 230px !important; "><param name="allowfullscreen" value="true"><param name="allowscriptaccess" value="always"><param name="flashvars" value="file=' + flashvars.file + '&streamer=' + flashvars.streamer + '"></object>' });
My job is to resize the <object> based on its container so I use.Code:this.removeAll(true, true); this.add(video);
My onResizeChange callback.Code:this.sizeMonitor = new Ext.util.SizeMonitor({ element : video.getEl(), callback : this.onSizeChange, scope : this });
When user presses back button and comes again to that view the same panel with object element is added and new sizeMonitor is set. But this time the added panel and object element which was destroyed is returned and not the new one.Code:onSizeChange : function() { var jwPlayer = Ext.get('jwplayer'); var jwPlayerContainer = Ext.get('jwPlayerContainer'); if(jwPlayer && jwPlayerContainer) { console.log(jwPlayer.dom); console.log(jwPlayerContainer.dom); jwPlayer.setWidth(jwPlayerContainer.getWidth()); jwPlayer.setHeight(jwPlayerContainer.getHeight()); } }
Is that a known bug?
-
1 Feb 2012 8:02 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
- Answers
- 3102
When you do this.add... are you recreating the panel?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
1 Feb 2012 8:13 AM #3
Here's the function that is being called from outside the view. This function is called from other views.
Code:addVideoPlayer : function(url, thumbnail) { //split link into two parts var urlSplitted = url.match(/^(.*)\/([^\/]+)$/); var flashvars = { file : urlSplitted[2], streamer : urlSplitted[1] }; flashvars = { file : 'live', streamer : 'rtmp://fms-live.xstream.dk/bb_live' }; this.remove(this.jwplayer, true); this.jwplayer = Ext.create('Ext.Panel', { id : 'jwPlayerContainer', html : '<object type="application/x-shockwave-flash" id="jwplayer" name="jwplayer" data="jwplayer/player.swf" width="480" height="270" style="width: 1286px !important; height: 230px !important; "><param name="allowfullscreen" value="true"><param name="allowscriptaccess" value="always"><param name="flashvars" value="file=' + flashvars.file + '&streamer=' + flashvars.streamer + '"></object>' }); this.add(this.jwplayer); this.sizeMonitor = new Ext.util.SizeMonitor({ element : this.jwplayer.getEl(), callback : this.onSizeChange, scope : this }); this.onSizeChange(); }
-
1 Feb 2012 8:15 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
- Answers
- 3102
After removal, have you checked the ComponentManager to see if the id is gone?
Personally, I would only use id for debugging, not production code.Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
1 Feb 2012 9:46 AM #5
Ok how can I have access to
ComponentManager? By Ext.ComponentManager? It seems private utility class.
Also why won't you use id? The <object> tag is added to the container as text markup.
-
1 Feb 2012 10:01 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
- Answers
- 3102
You are just checking to see if the id was removed for debugging.
I don't use id as you get collisions. ComponentQuery is a much better solution, your app has a hierarchy and can resolve a component based on this.Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
1 Feb 2012 3:11 PM #7
ComponentQuery is very flexible, however it has huge performance constraints, so we recommend you use id for unique components.
Please test your application using Beta 1. I know there were issues fixed with recreating components using an ID that was used before.Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
2 Feb 2012 2:13 AM #8
Here are my debugging results with PR4.
Ext.ComponentManager.get('jwPlayerContainer')
>Ext.apply.create.Class
Ext.ComponentManager.get('jwplayer')
undefined
Ext.ComponentQuery.query('object');
[]
Ext.ComponentQuery.query('object', Ext.ComponentManager.get('jwPlayerContainer'));
[]
-
2 Feb 2012 9:58 AM #9
If you are creating DOM using the html configuration, you need to use Ext.get to get an instance of your element, as it is not a component.
This will return an instance of Ext.dom.Element and you can work from there.Code:Ext.get('jwplayer');Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
7 Feb 2012 6:17 AM #10
I tried with Sencha Touch 2 beta 1 and the bug is also there.
I can reproduce the bug.
1. Add a panel with html div id set to something.
2. After some time (using setInterval), add an Button to that div using renderTo property.Code:html = '<div id="test-div-1"></div>';
3. Remove the button component.
4. Try Ext.get('id'); There is a instance but not what we want.


Reply With Quote