EasyUI Forum
April 27, 2024, 05:38:32 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: multiple overrides to the same event handler  (Read 9167 times)
korenanzo
Guest
« 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
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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/
Logged
korenanzo
Guest
« Reply #2 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?


Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #3 on: October 28, 2014, 01:20:17 AM »

Please read this documentation http://www.jeasyui.com/documentation/textbox.php.
Logged
korenanzo
Guest
« Reply #4 on: October 28, 2014, 01:37:34 AM »

I have already read it, thanks, it's ok
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!