Results 1 to 6 of 6

Thread: Ext.EventManager?

  1. #1
    Sencha Premium Member
    Join Date
    Sep 2013
    Posts
    99

    Default Answered: Ext.EventManager?

    Could someone please explain to me how Ext.EventManager works? I'm interested in it's onWindowResize() method, but I'm not sure how this works, where would I create the Ext.EventManager? and where would I call it's method? Let's say I wanted to call this simple function:

    Code:
    testFunction : function () {
        console.log('hello world');
    }
    every time the window resizes, could someone do a quick example on how this would work using an EventManager please?

  2. You can place it after you define your container.

    Code:
    var myPanel = Ext.create(..);
    Ext.EventManager.onWindowResize(myPanel.doLayout, myPanel);

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    You can track using the following:
    Code:
    Ext.EventManager.onWindowResize(myPanel.doLayout, myPanel);

  4. #3
    Sencha Premium Member
    Join Date
    Sep 2013
    Posts
    99

    Default

    Hey Scott, and where would I put that code to start 'listening'? If I put it in say, an afterRender event for myPanel, will it start listening for a window resize after myPanel is rendered and continue listening from then on? I guess that was my main inquiry. I won't be back on my computer till tomorrow to test this which is why I wanted to ask, thank you for the help btw.

  5. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    You can place it after you define your container.

    Code:
    var myPanel = Ext.create(..);
    Ext.EventManager.onWindowResize(myPanel.doLayout, myPanel);

  6. #5
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    You should also consider using removeResizeListener to remove the listener if your panel is destroyed.

    If you want to keep the resize logic wrapped up in your panel class I see no reason not to use an afterRender override. Personally I think I'd override onBoxReady instead (it's called after the first layout is complete) but officially that's a private method, so you may prefer to stick with afterRender.

  7. #6
    Sencha Premium Member
    Join Date
    Sep 2013
    Posts
    99

    Default

    works great, thanks scott and skirtle.

Posting Permissions

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