0

以前に次のスクリプトを使用しましたが、完全に機能しました。次のエラーが表示されます。

Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'.
jquery-latest.js (line 507)

jQueryUI 1.10.1 にアップグレードすると、エラーは発生しなくなりました。通常、私はそれを手放し、アップグレードし、心配することはありません. これの問題は、過去に機能していたので、なぜ今私を夢中にさせないのですか? 以前とは違う何かばかげたことをしているに違いないのですが、それがわかりません。

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>jQuery UI Dialog</title>
        <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script> 
        <link type="text/css" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" rel="stylesheet" />
        <script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js" type="text/javascript"></script> 
        <script>
            $(function() {
                $("#open").click(function(){$("#dialog").dialog('open');return false;});
                $( "#dialog" ).dialog({
                    modal: true,
                    autoOpen    : false,
                    buttons: {
                        Ok: function() {
                            $( this ).dialog( "close" );
                        }
                    }
                });
            });
        </script>
    </head>
    <body>
        <button id="open">Click</button>
        <div id="dialog" title="What ever"></div>
    </body>
</html>
4

1 に答える 1

0

ダイアログ宣言の外でボタン配列を定義することで解決した同様の問題がありました。

var buttonArray = {};
buttonArray["Ok"]=function() { $( this ).dialog( "close" );}

オプションは次のようになります。

     モーダル: 真、
     オートオープン: false,
     ボタン: ボタン配列
于 2013-11-05T20:03:48.403 に答える