jQuery UI对话框无法为我打开

时间:2019-02-17 13:14:29

标签: javascript jquery

HTML:

<button type="button" class="btn btn-success" style="margin-bottom:14px" id="btnAdd" onclick="modaladdedit('URLToMyController')"><i class="fa fa-plus"> Add New</i></button>

HEAD标签:

<link rel="stylesheet" href="/Content/themes/base/jquery-ui.min.css" />            
<script src="/Scripts/jquery-3.3.1.js"></script>
<script src="/Scripts/bootstrap.min.js"></script>
<link rel="stylesheet" href="/Content/bootstrap.min.css">
<link rel="stylesheet" href="/Content/font-awesome.min.css">
<link rel="stylesheet" href="/Content/ionicons.min.css">
<link rel="stylesheet" href="/admin-lte/css/AdminLTE.min.css">
<link rel="stylesheet" href="/admin-lte/css/skins/skin-black-light.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">        
<link href="/Content/jquery.dataTables.min.css" rel="stylesheet"/>
<link href="/Content/datatablefooteredit.css" rel="stylesheet"/>
<script src="/Scripts/jquery-ui-1.12.1.min.js"></script>
<script src="/Scripts/jquery.dataTables.min.js"></script>
<script src="/Scripts/dataTables.bootstrap.min.js"></script>

</body>之后:

<script src="/Scripts/jquery.slimscroll.min.js"></script>
<script src="/Scripts/fastclick.js"></script>
<script src="/admin-lte/js/adminlte.min.js"></script>
<script src="/admin-lte/js/demo.js"></script>

</body>之后的脚本:

$(document).ready(function () {
    $('.sidebar-menu').tree()
});

 var Popup, table;
 $(document).ready(function () {
// Some code here...
});

// Popup Modal Window
        function modaladdedit(url){            
            var formDiv= $('</div>');    
            $.get(url)
            .done(function(response){
                  formDiv.html(response);    
                  Popup= formDiv.dialog({
                    autoOpen: true,
                    resizable: false,
                    position: 'center',
                    modal: true,
                    title: 'Add/Edit Email Data',
                    height: 500,
                    width: 600,
                    close: function (){
                                Popup.dialog('destroy').remove();
                            }
                 });                    
            });

当我单击按钮时,对话框窗口不会弹出,并且在控制台中没有出现任何错误。 我尝试了一切,但没有任何效果。我尝试更改css和js文件的顺序,但没有任何效果。 任何帮助将不胜感激。

谢谢!

1 个答案:

答案 0 :(得分:1)

这甚至创建了<div>吗?

$('</div>')

我不确定它是否可以自动更正,但是/应该在末尾:

$('<div/>')

此外,即使创建formDiv,也永远不会将其附加到DOM。这样做的理想位置可能是在AJAX回调中。像这样:

formDiv.html(response);
$('body').append(formDiv);

您可以将其附加到您真正喜欢的任何地方,我只是以<body>元素为例。

相关问题