EasyUI Forum
September 14, 2025, 12:02:17 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [SOLVED]SwitchButton keyboard events  (Read 6685 times)
aiit
Newbie
*
Posts: 12


View Profile Email
« on: June 12, 2019, 04:16:45 PM »

I don't want switchbutton send onChange event by keyboard(Enter button), any one can solve it?
Here is my code:
Code:
    var sb = $('#sb')
    sb.next().attr('tabindex',1).bind('keyup',function(e){
   if (e.keyCode == 13){
                 e.preventDefault();
   }
    });
Thanks
« Last Edit: June 13, 2019, 04:51:24 AM by aiit » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 12, 2019, 07:13:22 PM »

Please rewrite the 'keydown.switchbutton' event handler.
Code:
$('#sb').next().unbind('keydown.switchbutton').bind('keydown.switchbutton', function(e){
if (e.keyCode == 32){
var opts = $('#sb').switchbutton('options');
$('#sb').switchbutton(opts.checked ? 'uncheck' : 'check')
}
});
Logged
aiit
Newbie
*
Posts: 12


View Profile Email
« Reply #2 on: June 13, 2019, 04:50:47 AM »

Thanks for quick reply.

Works great.
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!