我在使用 IE6 中的 Enter 键以及 jQuery UI 对话框确认框时遇到一些问题,该确认框上只有一个“确定”按钮。
$("#myBox").dialog({
autoOpen: false,
closeOnEscape: false,
resizable: false,
modal: true,
draggable: false,
position: ["center", 100],
buttons: {
'Ok': function() {
$(this).dialog("close");
closeReq();
}
}
});
基本上,我只希望对话框以及针对“确定”的任何其他函数调用一起关闭/触发函数,只有当用户单击“确定”按钮时。
目前,我允许用户按“Enter”键来启动某些信息的检索,然后基于对这些数据的一些验证,我生成了一个模态 jQuery UI 对话框,但似乎会自动从用户从一开始就按下“Enter 键”。
如何防止这种情况发生,即在 IE6 中禁用此 jQueryUI 对话框消息框的“Enter”键?
谢谢。
最佳答案
At the moment, I allow the user to press the "Enter" to fire off the retrieval of some info and then based on some validation of this data
无论您在哪里这样做,请调用
.preventDefault();
.stopPropagation();
在您的事件处理程序中。返回 false
就像一个快捷方式。
关于jquery - 使用 jQueryUI 对话框确认时如何停用 "Enter Key",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3243689/