1. #1
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    229
    Answers
    10
    Vote Rating
    1
    umr.ashrf is on a distinguished road

      0  

    Default 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.

    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 + '&amp;streamer=' + flashvars.streamer + '"></object>'
    });
    I remove all components and then add this to the view.
    Code:
    this.removeAll(true, true);
    this.add(video);
    My job is to resize the <object> based on its container so I use.

    Code:
    this.sizeMonitor = new Ext.util.SizeMonitor({
        element : video.getEl(),
        callback : this.onSizeChange,
        scope : this
    });
    My onResizeChange callback.

    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());
        }
    }
    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.

    Is that a known bug?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,125
    Answers
    3504
    Vote Rating
    855
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    When you do this.add... are you recreating the panel?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    229
    Answers
    10
    Vote Rating
    1
    umr.ashrf is on a distinguished road

      0  

    Default


    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 + '&amp;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();
    }

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,125
    Answers
    3504
    Vote Rating
    855
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    229
    Answers
    10
    Vote Rating
    1
    umr.ashrf is on a distinguished road

      0  

    Default


    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.

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,125
    Answers
    3504
    Vote Rating
    855
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  7. #7
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Answers
    93
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    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.

  8. #8
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    229
    Answers
    10
    Vote Rating
    1
    umr.ashrf is on a distinguished road

      0  

    Default


    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'));
    []

  9. #9
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Answers
    93
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    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.

    Code:
    Ext.get('jwplayer');
    This will return an instance of Ext.dom.Element and you can work from there.
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  10. #10
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    229
    Answers
    10
    Vote Rating
    1
    umr.ashrf is on a distinguished road

      0  

    Default


    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.
    Code:
    html = '<div id="test-div-1"></div>';
    2. After some time (using setInterval), add an Button to that div using renderTo property.
    3. Remove the button component.
    4. Try Ext.get('id'); There is a instance but not what we want.

Thread Participants: 2