6 Jul 2010 1:22 AM #1
Toolbar button handler question
I have just modified the JSONP example to try and display different content when I click on some test buttons in a toolbar.
However, the handler events for the toolbar seem to be firing when the page loads and then do not fire when you click on the buttons. The panel definition is:
text: 'Refresh Issues',
handler: getIssues (1991)
handler: getIssues (1978)
title: "Tap one of the buttons above."
The getIssues function is declared above this - I have an alert in it and it displays the data and year parameters, 1991 and 1978 when the page loads.
Am I doing something wrong here?
6 Jul 2010 10:26 AM #2
You are actually calling the handler methods (by adding the parentheses). Try just using getIssues, and then based on the button that is clicked you decide the year.
6 Jul 2010 10:37 AM #3
Thanks - I can see what what was happening now and the page is working OK. I called 2 different functions which displayed the years.
Where would you test for the button that was pressed? Is there a last event property or something that could be examined?
6 Jul 2010 1:36 PM #4
The btn is passed to the handler as the first argument. Also the default scope references the button, so inside your handler 'this' should point to the button that was pressed.
7 Jul 2010 1:05 AM #5
Got it - used the parameter to get the buttons properties - using btn.getText() and called methods like btn.disable() - also added custom property to the button config definition ('pyear') and accessed this as btn.pyear within the handler function.
It is much clearer now.
By tBSTAR in forum Ext 3.x: Help & DiscussionReplies: 4Last Post: 30 Dec 2009, 6:43 AM
By xplicit in forum Ext 2.x: Help & DiscussionReplies: 8Last Post: 9 Aug 2008, 4:14 PM
By weyus in forum Ext 2.x: Help & DiscussionReplies: 13Last Post: 17 Jul 2008, 2:30 PM
By dddu88 in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 14 Mar 2008, 6:33 AM