When dialog opens I focus it with $(this).parents( ...
and when ENTER key is pressed it should execude but it's not. How to execute it when ENTER key pressed?
当对话框打开时,我把它集中在$(this).parents(...当按下ENTER键时它应该执行但不是。当按下ENTER键时如何执行它?
open: function() {
$(this).parents('.ui-dialog-buttonpane button:eq(0)').focus();
$("#DIALOG2").keydown(function(event) {
if (event.which == 13) { //EXECUTE!
$(this).dialog("close");
ajax_usun(del_id);
}
});
}
JSfiddle with example: (click on delete button and instaed of pressing buttons in dialog with mouse press enter - nothing happens) http://jsfiddle.net/FkbLT/2/
JSfiddle with example :(单击删除按钮并在对话框中按下按钮,用鼠标按下输入 - 没有任何反应)http://jsfiddle.net/FkbLT/2/
1 个解决方案
#1
1
EDIT:
I've found out the problem.
我发现了问题。
show: 'scale',
is causing the focus to not be applied, probably because it tries (and fails) to apply the focus when the "scale" effect is still running, then when scale effect is over, you have no focus on the button.
导致焦点不被应用,可能是因为它在“缩放”效果仍在运行时尝试(并失败)应用焦点,然后当缩放效果结束时,您没有关注按钮。
Fiddle: http://jsfiddle.net/VjakR/
EDIT 2: DEFINITELY a JQuery Bug, i've tried all the 'show' possible settings, and it turned out that it works with:
编辑2:绝对是一个JQuery Bug,我已经尝试了所有'show'可能的设置,结果证明它适用于:
blind
clip
drop
fold
puff
slide
size
pulsate
while it breaks with:
虽然它打破了:
scale
explode
Just choose another one, and/or report this bug to JQuery developers...
只需选择另一个,和/或向JQuery开发人员报告此错误......
#1
1
EDIT:
I've found out the problem.
我发现了问题。
show: 'scale',
is causing the focus to not be applied, probably because it tries (and fails) to apply the focus when the "scale" effect is still running, then when scale effect is over, you have no focus on the button.
导致焦点不被应用,可能是因为它在“缩放”效果仍在运行时尝试(并失败)应用焦点,然后当缩放效果结束时,您没有关注按钮。
Fiddle: http://jsfiddle.net/VjakR/
EDIT 2: DEFINITELY a JQuery Bug, i've tried all the 'show' possible settings, and it turned out that it works with:
编辑2:绝对是一个JQuery Bug,我已经尝试了所有'show'可能的设置,结果证明它适用于:
blind
clip
drop
fold
puff
slide
size
pulsate
while it breaks with:
虽然它打破了:
scale
explode
Just choose another one, and/or report this bug to JQuery developers...
只需选择另一个,和/或向JQuery开发人员报告此错误......