-
9 Mar 2011 5:37 AM #1
Multiple Ext.Button handlers
Multiple Ext.Button handlers
is there a way to put multiple handlers on a button, so it starts multiple functions at once??

something like, open all button??
Code:Ext.onReady(function() { var myButtonAll = new Ext.Button({ text : "OPEN ALL", handler : varname, varname...??? renderTo : "buttons", scale : "large", iconCls : "button_two", width : 100, height : 100, }); });
-
9 Mar 2011 6:25 AM #2
Since the "handler" config option just assigns the function to the click event of the button... you can add multiple click events to your button like this:
Or you can wrap all of them in an anonymous function like this:Code:Ext.onReady(function() { var myButtonAll = new Ext.Button({ text : "OPEN ALL", handler : varname, varname...??? renderTo : "buttons", scale : "large", iconCls : "button_two", width : 100, height : 100, }); myButtonAll.on('click', handler1); myButtonAll.on('click', handler2); myButtonAll.on('click', handler3); myButtonAll.on('click', handler4); });
And the handlers should have the signature of the button click handler, for example:Code:Ext.onReady(function() { var myButtonAll = new Ext.Button({ text : "OPEN ALL", handler : function() { handler1.apply(this, arguments); handler2.apply(this, arguments); handler3.apply(this, arguments); handler4.apply(this, arguments); } renderTo : "buttons", scale : "large", iconCls : "button_two", width : 100, height : 100, }); });
Code:handler1 = function(button, event) {...}Johnathan Hebert
-
9 Mar 2011 6:54 AM #3Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
You don't need to be an anonymous function. Adding multiple event listeners will affect performance. Best way to do it is have a wrapping function.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
10 Mar 2011 1:52 AM #4
thank you very much, i did the wrapping , it works!!!

Similar Threads
-
Ext.form.SliderField with multiple handlers?
By apopescu in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 9 Apr 2010, 9:24 AM -
Multiple event handlers that modifies the same value
By dolittle in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 3 Nov 2008, 8:34 AM -
Multiple Handlers
By say2paul in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 24 Jan 2008, 11:52 PM


Reply With Quote