EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: noerone on March 05, 2016, 10:07:21 PM



Title: how do I choose "cancel" with other keys in Messager.confirm ?
Post by: noerone on March 05, 2016, 10:07:21 PM
I want to ask about Messager.confirm .

usually when I want to select cancel , I use the tab key on the keyboard . how do I choose cancel with other keys ( example : right arrow )


Title: Re: how do I choose "cancel" with other keys in Messager.confirm ?
Post by: jarry on March 06, 2016, 01:20:44 AM
The code below implements the navigating feature using the 'LEFT' and 'RIGHT' keys.
Code:
<script type="text/javascript">
(function($){
function nav(delta){
var win = $('body').children('div.messager-window');
if (!win.length){return}
var buttons = win.find('.messager-button .l-btn');
for(var i=0; i<buttons.length; i++){
if ($(buttons[i]).is(':focus')){
var index = i + delta;
if (index > buttons.length-1){
index = 0;
} else if (index < 0){
index = buttons.length-1;
}
$(buttons[index]).focus();
return false;
}
}

}
$(document).bind('keydown', function(e){
if (e.keyCode == 39){ // right
return nav(1);
} else if (e.keyCode == 37){ // left
return nav(-1);
}
})
})(jQuery);
</script>


Title: Re: how do I choose "cancel" with other keys in Messager.confirm ?
Post by: noerone on March 06, 2016, 01:52:05 AM
Thanks Jarry. It's work  ;D

[Thread Closed]