EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: aiit on June 12, 2019, 04:16:45 PM



Title: [SOLVED]SwitchButton keyboard events
Post by: aiit 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


Title: Re: SwitchButton keyboard events
Post by: stworthy 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')
}
});


Title: Re: SwitchButton keyboard events
Post by: aiit on June 13, 2019, 04:50:47 AM
Thanks for quick reply.

Works great.