Page 3 of 3 FirstFirst 123
Results 21 to 28 of 28

Thread: DockLayout attempts to manipulate DOM element after it's been destroyed

    Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-236 in a recent build.
  1. #21
    Sencha User
    Join Date
    Jul 2011
    Location
    Melbourne
    Posts
    11

    Default

    Hi, I'm getting
    Uncaught TypeError: Cannot read property 'parentNode' of undefined
    when trying to recreate the Panel, and the panel doesn't have docked Items.

    The code for recreating a panel is

    myPanel = new Ext.Panel({
    title : 'title',
    layout : {
    type: 'vbox',
    },
    items: [item1, item2],
    defaults : {
    layout : {
    type : 'hbox'
    }
    margin: '5%'
    }
    }
    });


    rootPanel.add(myPanel);
    rootPanel.render(document.body);
    rootPanel.setActiveItem(myPanel, leftSlide);
    rootPanel.doComponentLayout();

    But if I have no items, but, say,
    html: 'here should be items'
    this works fine.

    Thank you for any hints.

  2. #22

    Default

    Try not to set the items on the initialization config options, set them on the init of the component. I found that setting items in the config (or using xtypes) is sometimes buggy when you destroying and recreating. So try:


    Code:
    var panel = new Ext.Panel({     
        id: 'MyPanel',
        initComponent: function() {
            this.add(item1);
            this.add(item2);
        } 
    };  

  3. #23
    Sencha - Support Team keckeroo's Avatar
    Join Date
    Mar 2008
    Location
    Winnipeg, Canada
    Posts
    387

    Default

    The workaround of 'afterrender' seems to work for me ... but yeesh, sorry guys, this is a big problem and would be great if this could be patched as optimizing memory is a big thing for these apps.

    Cheers and thanks.

    SUGGESTION: How about putting some WARNINGS in the DOCUMENTATION about bugs for a particular method and a link to the forum where it is documented? In this case I referenced and re-referenced the REMOVE method for Ext.Panel and it would have saved me two days worth of tracing had a little snippet be in there. I think we all can agree that most of us heavily utilize the documentation and keeping it up to date and accurate is *paramount* for most of us and makes the bugs a little easier to swallow - except for cockroaches - they're just GROSS ;-)

    PS - the online docs STILL don't have both plugins for pullrefresh and listpaging updated and corrected. :-(

  4. #24
    Sencha - Support Team keckeroo's Avatar
    Join Date
    Mar 2008
    Location
    Winnipeg, Canada
    Posts
    387

    Default Important note to the 'workaround'...

    Don't forget to do your layout

    Code:
    this.addDocked([ 
     ....
    ]);
    this.doLayout();
    'fit' items won't scroll properly without it ... :-)

  5. #25
    Sencha - Support Team keckeroo's Avatar
    Join Date
    Mar 2008
    Location
    Winnipeg, Canada
    Posts
    387

    Default

    Ugh - I give up on this one and will abandon trying to do optimization for now.

    Anything that's more complex than a simple panel just won't work. I had a panel with dock items working fine - but then add stuff like actual complex content to the panel items (i had a list with a store, template, functions) it just craps out. This time with no errors.

    The panel loaded fine - but the store contained the same data from before and the list was at the same position as previous - something that shouldn't happen if it was a brand new instantiate list.

    Back to the drawing board.

    If anyone wants to view the code - let me know - i'd be happy to share the whole thing.

    Kev

  6. #26

    Default Not just an optimization necessity...

    Our app requires content to be cleared between logout and re-logging in. We could simply reload all the content (it'll be wrapped in PhoneGap), but the added latency is undesirable.

    Removing and recreating TabPanels (whether docked components are added in properties or in init) still results in the error:
    Cannot read property 'parentNode' of undefined

  7. #27
    Sencha User
    Join Date
    May 2011
    Posts
    12

    Default

    Hi,
    the general hack to that problem is never having any static component in a class you want to remove and recreate. Instead you have to do something like this :
    Code:
    myPanel  = Ext.Extend(...,{
       myItem : false,
       getMyItem : function(){
          if(!this.myItem)
             this.myItem = new ... ;
          return this.myItem;
     }),
     listeners : {
        beforerender : function(){
           this.add(this.getMyItem());
           this.doComponentLayout();
       }
     }
    });

  8. #28
    Sencha User
    Join Date
    Aug 2011
    Posts
    15

    Default

    I've been trying to implement the beforerender hack, and it seems to be working, except if the panel has a List inside, the height of the list isn't taking in account the added toolbar, and doesn't let me scroll to the last element, because (i think) it behaves like there is more height available.


    Is there any override for fixing this?? Or when should i call doComponentLayout(); ??

    I've been calling it like this, but as I said above, isn't working :

    PHP Code:
    beforerender : function ()        
    {            
    this.addDocked            (                {                    
    xtype'toolbar',                    
    docked"top",                   
     
    titleRESOURCES.list_title_atms,                   
     
    items:                    [                    ]                }            );            this.doComponentLayout();         

    The Sencha Team should fix that entry in the blog, the one about Optimizing memory, because is outdated and misleading

Page 3 of 3 FirstFirst 123

Similar Threads

  1. Replies: 2
    Last Post: 1 Oct 2010, 7:00 PM
  2. manipulate a HTML select element
    By xun in forum Community Discussion
    Replies: 5
    Last Post: 23 Sep 2010, 10:30 AM
  3. is closable Ext.Window destroyed from dom on close?
    By andynuss in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 22 Oct 2009, 3:48 AM
  4. Replies: 6
    Last Post: 19 Mar 2009, 12:31 PM
  5. newbie question: how can I use Extjs to manipulate DOM
    By orixilus in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 9 Jul 2008, 7:29 AM

Posting Permissions

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