Results 1 to 10 of 10

Thread: Same ID Component Bug

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    229
    Answers
    10
    Vote Rating
    2
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    When you do this.add... are you recreating the panel?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    229
    Answers
    10
    Vote Rating
    2
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  5. #5
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    229
    Answers
    10
    Vote Rating
    2
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •