jQuery Dialog UI无法在IE中运行

时间:2012-11-26 16:10:28

标签: jquery jquery-ui

我有以下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>&nbsp;

是否有任何技巧可以让它与IE一起使用?

1 个答案:

答案 0 :(得分:2)

试试这个:

$("#btnTransfer").button().on('click', function (e) {
    e.preventDefault();
    $("#dialog-form").dialog("open");
});

...而不是return false;