Threaded View
-
6 Dec 2012 8:16 AM #1
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:
I would be very grateful for any help.Code:onMenuitemClick: function(item, e, options) { //alert('Item clicked!'); //thats working Ext.getCmp('MyForm') ; //return undefined //Ext.getCmp('MyForm').getLayout().setActiveItem(1); }
-
Best Answer Posted by suzuki1100nz
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


Reply With Quote