1. #1
    Ext User samotnik's Avatar
    Join Date
    Apr 2010
    Posts
    68
    Vote Rating
    0
    samotnik is on a distinguished road

      0  

    Default panel 'afterrender' is not working

    panel 'afterrender' is not working


    hello.
    Can you please help me.
    I try add Listener to panel, but it is not working
    I have a panel :
    Code:
    var panelBody = this.getEl().child('.x-panel-body');
    And I try add listener to it
    Code:
    panelBody.on('afterrender', function() {
    alert(1);}
    , this);
    But nothing happens

    And this
    Code:
    Ext.EventManager.on(panelBody, 'afterrender', function() {
                alert('afterrender ! ');
            });
    is not working, too

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    57
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    If you add the listener after it has rendered, the event won't get fired again.

  3. #3
    Ext User samotnik's Avatar
    Join Date
    Apr 2010
    Posts
    68
    Vote Rating
    0
    samotnik is on a distinguished road

      0  

    Default


    mr. Animal, thank you !

  4. #4
    Ext User samotnik's Avatar
    Join Date
    Apr 2010
    Posts
    68
    Vote Rating
    0
    samotnik is on a distinguished road

      0  

    Default


    ok, then, I have another question
    How can I know, when All content was add to the panel ?
    'afterrender' alert before loaded all content in the panel

  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    57
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    You might be thinking of the afterlayout event.

    You will need to use {single: true} to only catch the first layout event.

  6. #6
    Ext User samotnik's Avatar
    Join Date
    Apr 2010
    Posts
    68
    Vote Rating
    0
    samotnik is on a distinguished road

      0  

    Default


    no, but in any case, thank you, mr. Animal !
    It seems, that I have to use defer() function, I know, that it's bad solution. But I really do not uderstand, how can I catch event, when all content will innerHTML to the panel, with all css ...




  7. #7
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    57
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Oh, you are not using the Panel as a Container then, but dumping some dead HTML into it?

    You don't need events then. Just perform postprocessing after you've dumped the HTML in.

  8. #8
    Ext User samotnik's Avatar
    Join Date
    Apr 2010
    Posts
    68
    Vote Rating
    0
    samotnik is on a distinguished road

      0  

    Default


    thank you, mr.Animal !!
    How do you think, is it possible or not ?
    I have a panel. panel, and I do innerHTML to it
    Code:
    panel.update(some_html);
    and then (on the next line) I try to get offsetTop of one element from that panel. But calculate is wrong. But, if I use defer() function or just alret('bla bla bla') - calculate is right !
    For example
    Wrong offset:
    Code:
    panel.update(some_html);
    alert(Ext.get('id9').dom.offsetTop); // this offset is wrong !!! It is 2100
    Right offset
    Code:
    panel.update(some_html);
    alert('this is just alert for take time of panel' rendering. When you press ok button, all contents of panel will render right');
    alert(Ext.get('id9').dom.offsetTop); // this offset is right !!! It is 3200
    Right offset
    Code:
     (function(){
                    alert(Ext.get('id9').dom.offsetTop); // this offset is right !!! It is 3200
                }).defer(500);

  9. #9
    Ext User samotnik's Avatar
    Join Date
    Apr 2010
    Posts
    68
    Vote Rating
    0
    samotnik is on a distinguished road

      0  

    Default


    Why my post was not added ?

  10. #10
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    57
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    If it's a large block, and it updates asynchronously (which it seems to be) Then try using the callback option to update.

    http://www.sencha.com/deploy/dev/doc...&member=update

Similar Threads

  1. Panel and afterrender problem
    By ChiefDanGeorge in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 15 Apr 2010, 9:44 AM
  2. afterRender not firing
    By yyogev in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 19 Oct 2009, 4:10 AM
  3. [SOLVED] Panel plugin problem - how to add 'afterrender' event
    By nugatto in forum Ext 2.x: Help & Discussion
    Replies: 11
    Last Post: 30 Jun 2008, 11:24 PM

Thread Participants: 1