You found a bug! We've classified it as EXTJSIV-7500 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    678
    Vote Rating
    62
    Daniil is a jewel in the rough Daniil is a jewel in the rough Daniil is a jewel in the rough Daniil is a jewel in the rough

      0  

    Default [4.1.2] TableLayout + IE8: calling doLayout after hidding an item causes a JS error

    [4.1.2] TableLayout + IE8: calling doLayout after hidding an item causes a JS error


    REQUIRED INFORMATION

    Ext version tested:
    • Ext 4.1.2
    Browser versions tested against:
    • IE8 - throws a JavaScript error
    • IE9 - OK
    • Chrome - OK
    • FireFox - OK
    Description:
    • Working on some issue, I discovered that calling doLayout() for a container with TableLayout after hiding some item causes a JavaScript error in IE8. Generally, it is not required to call doLayout() in the example below (it is just a test case to reproduce), but, I think, it should not cause an error.
    • The error "tagName is null or not an object" occurs here:
      Code:
      ensureInDocument: function (el) {
          var dom = el.dom.parentNode;
          while (dom) {
              if (dom.tagName.toUpperCase() == 'BODY') {
                  return;
              }
              dom = dom.parentNode;
          }
      
          Ext.getDetachedBody().appendChild(el);
      }
    Steps to reproduce the problem:
    • Run the sample in IE8 (it is reporducible in IE9 with IE8 mode as well)
    • Click the button
    The result that was expected:
    • No error
    The result that occurs instead:
    • A JavaScript error occurs
    Test Case:

    Code:
    <html>
    <head>
        <title>TableLayout hide item</title>
    
        <link type="text/css" rel="stylesheet" href="../resources/css/ext-all.css" />
        
        <script type="text/javascript" src="../ext-all-debug.js"></script>
    
        <script type="text/javascript">
            Ext.onReady(function () {
                Ext.create("Ext.container.Container", {
                    renderTo: Ext.getBody(),
                    layout: "table",
                    items: [{
                        xtype: "button",
                        text: "Hide label",
                        handler: function () {
                            var ct = this.up("container");
                            ct.child("label").hide();
                            
                            ct.doLayout(); // actually, it is not required, but reproduces the issue.
                        }
                    }, {
                        xtype: "label",
                        text: "Label"
                    }]
                });
            });
        </script>
    </head>
    <body>
    
    </body>
    </html>


  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,599
    Vote Rating
    434
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    3
    Vote Rating
    0
    gruszks is on a distinguished road

      0  

    Default


    There is any quick fix for it?

  4. #4
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    678
    Vote Rating
    62
    Daniil is a jewel in the rough Daniil is a jewel in the rough Daniil is a jewel in the rough Daniil is a jewel in the rough

      0  

    Default


    Maybe this workaround. Actually, this is not a fix. I didn't investigate a root of the problem. But, at least, it allows to avoid an error.

    Workaround
    Code:
    Ext.layout.container.Table.override({
        ensureInDocument: function(el){
            var dom = el.dom.parentNode;
            while (dom) {
                if (dom.tagName && dom.tagName.toUpperCase() == 'BODY') {
                    return;
                }
                dom = dom.parentNode;
            } 
            
            Ext.getDetachedBody().appendChild(el);
        }
    });
    Ext.NET - ASP.NET for Ext JS
    MVC and WebForms
    Examples | Twitter

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    3
    Vote Rating
    0
    gruszks is on a distinguished road

      0  

    Default


    This is only workaround for silent the javascript error.
    But the label isn't shown when you do something like this:
    Code:
    var label = Ext.ComponentQuery.query("label")[0];
    label.show();
    label.updateLayout();

  6. #6
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    678
    Vote Rating
    62
    Daniil is a jewel in the rough Daniil is a jewel in the rough Daniil is a jewel in the rough Daniil is a jewel in the rough

      0  

    Default


    Sadly. Maybe you could wrap the Label in an additional Container?
    Ext.NET - ASP.NET for Ext JS
    MVC and WebForms
    Examples | Twitter