1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    2
    Vote Rating
    0
    pawelp7 is on a distinguished road

      0  

    Default Answered: Click event handler problem

    Answered: Click event handler problem


    Hi!

    I am considering if it's possible to call setActiveItem from button's click event handler. I'm using Sencha Architect, I've tried several methods, but without luck. I was trying to run the code:

    Code:
    onMenuitemClick: function(item, e, options) {
           
         //alert('Item clicked!'); //thats working
      
      Ext.getCmp('MyForm') ; //return undefined
            //Ext.getCmp('MyForm').getLayout().setActiveItem(1);
    }
    I would be very grateful for any help.

  2. ok
    Ext.getCmp(...) searches for a component with the matching config id.
    Does your form have an id of "myForm".
    I suspect not.

    What is better practice is to set an itemId on your form and use the button "up" method to find the form.
    See - http://docs.sencha.com/touch/2-1/#!/...tton-method-up

    Now this is using a component query relative to the button looking up. See Ext.ComponentQuery in the API for details around query selectors (you could use Ext.ComponentQuery singleton to find the form as well).

    http://docs.sencha.com/touch/2-0/#!/...ComponentQuery

    Assumming you give your form the itemid of "baseForm" your button query would look like.

    button.up('#baseForm');

    Good luck

  3. #2
    Touch Premium Member suzuki1100nz's Avatar
    Join Date
    Apr 2011
    Location
    New Zealand
    Posts
    464
    Vote Rating
    68
    Answers
    21
    suzuki1100nz is just really nice suzuki1100nz is just really nice suzuki1100nz is just really nice suzuki1100nz is just really nice

      1  

    Default


    ok
    Ext.getCmp(...) searches for a component with the matching config id.
    Does your form have an id of "myForm".
    I suspect not.

    What is better practice is to set an itemId on your form and use the button "up" method to find the form.
    See - http://docs.sencha.com/touch/2-1/#!/...tton-method-up

    Now this is using a component query relative to the button looking up. See Ext.ComponentQuery in the API for details around query selectors (you could use Ext.ComponentQuery singleton to find the form as well).

    http://docs.sencha.com/touch/2-0/#!/...ComponentQuery

    Assumming you give your form the itemid of "baseForm" your button query would look like.

    button.up('#baseForm');

    Good luck

  4. #3
    Sencha User
    Join Date
    Dec 2012
    Posts
    2
    Vote Rating
    0
    pawelp7 is on a distinguished road

      0  

    Default


    Thanks! I added an ID for main panel and ended with something like
    Code:
    button.up('#baseForm').layout.setActiveItem(1);
    in my button event handler. Now it works!

Thread Participants: 1