-
8 Jul 2010 8:45 AM #1
scope of handler
scope of handler
I have a button nested 2 levels deep and am trying to call a function on the top level, but can't get it to work. I set the scope to 'parent' and tried 'parent.parent'. See code below, the handler is "handler: doAlert"
var tabpanel = new Ext.TabPanel({
tabBar: {
dock: 'bottom',
layout: {
pack: 'center'
}
},
fullscreen: true,
ui: 'light',
activeItem: 0,
animation: {
type: 'flip',
cover: true
},
items: [{
title: 'Map',
cls: 'card4',
iconCls: 'settings',
xtype: 'map',
items:[mapdemo],
}, {
title: 'Search',
cls: 'card1',
iconCls: 'user',
items: [{
xtype: 'textfield',
name : 'address',
label: 'Address'
}],
dockedItems: [
{
xtype: 'toolbar',
dock: 'bottom',
items: [
{
text: 'Search',
ui: 'round',
handler: doAlert,
scope:parent
}
]
}
]
}]
});
//
var doAlert = function(btn, event){
alert('DO IT')
}
-
8 Jul 2010 5:44 PM #2
You can't do that, "parent" isn't a valid scope.
The problem you're facing is that none of the objects are actually created, the whole RHS is evaluated before the tabPanel variable is assigned. The best way would be to use an id to grab the component.Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
9 Jul 2010 6:48 AM #3
Thank you. Could you let me know how to set and retrieve the id of a component? or point me to this documentation?
thanks!
-
13 Jul 2010 11:37 AM #4Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 4
Every component has an id config option, and you can retrieve a component using Ext.getCmp. You might however want to break up your source code and define individual instances to variables so you can easily reference them.
Similar Threads
-
Scope for Direct handler
By makcs in forum Ext.DirectReplies: 2Last Post: 27 Dec 2009, 8:54 AM -
Handler scope
By bkraut in forum Ext 3.x: Help & DiscussionReplies: 4Last Post: 7 Jul 2009, 1:09 AM -
Action handler scope
By john.brown in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 18 Sep 2008, 12:41 PM -
Scope Within Tool Handler???
By arth in forum Ext 2.x: Help & DiscussionReplies: 7Last Post: 10 Sep 2008, 11:16 AM


Reply With Quote

