我有以下 Jquery 代码,它在使用 FF 或 Chrome 的 .aspx 页面中运行良好。但是,在 IE9 中,当我单击本应打开对话框的按钮时,它似乎只是刷新了整个页面,但没有任何反应。
我正在使用这些版本:
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
这是我的 jquery:
$(function () {
$("#btnSearch").click(function () {
$("#gvBox").show();
});
$("#dialog-form").dialog({
autoOpen: false,
height: 400,
width: 650,
modal: true,
buttons: {
"Transfer": function () {
var bValid = true;
allFields.removeClass("ui-state-error");
if (bValid) {
$(this).dialog("close");
}
},
Cancel: function () {
$(this).dialog("close");
}
},
close: function () {
allFields.val("").removeClass("ui-state-error");
},
open: function () {
{
$(this).parent().appendTo($("form:first"));
}
}
});
$("#btnTransfer").button().click(function () {
$("#dialog-form").dialog("open");
return false;
});
return false;
});
这是我打开对话框的按钮:
<button id="btnTransfer">Transfer Ownership</button>
有什么技巧可以让它在 IE 上工作吗?
最佳答案
试试这个:
$("#btnTransfer").button().on('click', function (e) {
e.preventDefault();
$("#dialog-form").dialog("open");
});
...而不是返回 false;
关于jQuery 对话框 UI 在 IE 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13568649/