EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: korenanzo on October 24, 2014, 03:30:03 AM



Title: multiple overrides to the same event handler
Post by: korenanzo on October 24, 2014, 03:30:03 AM
Hi,
I need to bind different functions to an event, in different moments.

for regular js objects, it is:
$('#tt').bind({ focus: function (e) { console.log ("Doing A"); } });
...
$('#tt').bind({ focus: function (e) {  console.log ("Doing b"); } });
It works: on focus,  both A and B are printer on the console.

but this thing with inputEvents of textbox (for example) won't work, you will see only B.



$('#tt').textbox({
   inputEvents:$.extend({},$.fn.textbox.defaults.inputEvents,{
       focus: function (e) {  console.log ("Doing a"); }
   })
});

....

$('#tt').textbox({
   inputEvents:$.extend({},$.fn.textbox.defaults.inputEvents,{
       focus: function (e) {  console.log ("Doing b"); }
   })
});


Is there a workaround or another way to do it?

you can try it here http://jsfiddle.net/pug53mus/21/

thanks,
Ric


Title: Re: multiple overrides to the same event handler
Post by: jarry on October 24, 2014, 07:54:58 AM
You can not bind multiple functions to a single 'inputEvents'. In order to achieve that, please call 'textbox' method to get the input box and then bind multiple functions.
Code:
$('#b').textbox('textbox').bind('focus',function(){
    console.log('Doing C');
}).bind('focus',function(){
    console.log('Doing D');
});

Please refer to this updated example http://jsfiddle.net/pug53mus/22/


Title: Re: multiple overrides to the same event handler
Post by: korenanzo on October 28, 2014, 01:12:51 AM
You can not bind multiple functions to a single 'inputEvents'. In order to achieve that, please call 'textbox' method to get the input box and then bind multiple functions.

Thanks, it works:)

I'd like to have a more detailed documentation, does it exist?




Title: Re: multiple overrides to the same event handler
Post by: jarry on October 28, 2014, 01:20:17 AM
Please read this documentation http://www.jeasyui.com/documentation/textbox.php.


Title: Re: multiple overrides to the same event handler
Post by: korenanzo on October 28, 2014, 01:37:34 AM
I have already read it, thanks, it's ok