0

这是我的简单 jquery,它在 IE 中运行良好,但在 FF 和 Chrome 中无法运行

function publishRedirects() {
    if (window.confirm("Are you sure want to publish the redirects?")) {
        callJquery();
    }
}

function callJquery() {
    $('#btnPublish').click(function () {
        $("#dialog").attr('title', 'Publishing').text('Publishing Please Wait').append("<img src='../images/loading11.gif' id='myNewImage' />").dialog({
            draggable: false,
            resizable: false,
            modal: true,
            closeOnEscape: false,
            open: function (event, ui) {
                $("a.ui-dialog-titlebar-close").remove();
            }
        });
    });
}

这是我的 HTML:

<body> <div id="dialog"></div> <input name="btnPublish" class="button1" type="button" id="btnPublish" value="Publish" onClick="publishRedirects()"> <script type="text/javascript" src="../script/jquery.js"></script> <script type="text/javascript" src="../script/jquery-ui.js"></script> </body>
4

1 回答 1

1

我认为这是因为您将单击事件分配给 btnPublish 而不是执行该功能。如果在单击按钮时调用 publishRedirects() 并且您希望 callJquery 中的代码在用户确认对话框后执行,​​它应该看起来像这样:(注意删除的附加到单击事件)

    function callJquery(){
         var obj= $("#dialog");
         obj.attr('title','Publishing');
         obj.text('Publishing Please Wait');
         obj.append("<img src='../images/loading11.gif' id='myNewImage' />");
         obj.dialog({ 
                draggable: false,
                resizable: false,
                modal: true,
                closeOnEscape: false,
                open: function(event, ui) {
                       $("a.ui-dialog-titlebar-close").remove();
                  }
                 });

    }   
于 2012-06-27T10:20:14.390 回答