-1

我想在我的 mvc3 razor 应用程序中打开一个弹出窗口,因为我知道下面的代码。当我单击按钮时,什么都没有发生。我在错误控制台中看到一个错误“$(#dialog).dialog is not a function”。我是 jquery 的新手,任何人都可以帮助我我在做什么错误。

 $(function () {   
        $('#dialog').dialog({
            autoOpen: false,
            width: 400,
            resizable: false,
            title: 'hi there',
            modal: true,
            open: function(event, ui) {
                //Load the Edit action which will return 
                // the partial view _Edit
                $(this).load("@Url.Action("Edit")");
            },
            buttons: {
                "Close": function () {
                    $(this).dialog("close");
                }
            }
        });

        $('#Button1').click(function () {
            $('#dialog').dialog('open');
        });
    });  
4

1 回答 1

3

要使用.dialog,您必须在页面上加载 jQuery 和 jQueryUI。

将此添加到您的HEAD

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script>
于 2012-05-21T10:06:20.703 回答