简体   繁体   English

jQuery-ui对话框在单击事件中不显示

[英]jQuery-ui dialog don't show on click event

My jQuery-ui dialog don't show when clicking on a submit button 单击提交按钮时不显示我的jQuery-ui对话框

html : html:

<input id="pdfsub" type="button" name="pdfsub" value="PDF">

Javascript Java脚本

 $(document).ready(function() {

    $("#PDFdialog").dialog({
        width: 500, autoOpen: false, resizable: false, draggable: false,
        modal: false,
        title: "pdf",
        buttons: [
        {
            text: "Annuler",
            click: function() {
                $( this ).dialog( "close" );
            }
        }]
    });

    $("#pdfsub").click(function(){
        $("#PDFdialog").dialog("open");
        alert("btn");
    });
});

it show me my alert box but not the dialog , did I make a mistake somewhere ? 它显示了我的警报框,但没有显示对话框,我是否在某个地方犯了错误? also my jQuery and jQuery-ui libs are working (have the same in my "connexion" page with same dialog and it's working) 我的jQuery和jQuery-ui库也都在工作(在“ connexion”页面中具有相同的对话框并且工作正常)

EDIT : 编辑:

There are my libs 有我的库

<script src="/jquery-ui-1.12.1/external/jquery/jquery.js"></script> 
<script src="/jquery-ui-1.12.1/jquery-ui.min.js"></script>  
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

You are applying dialog function to a div that does not exist in your HTML structure and you don't create it in javascript/jquery either. 您正在将对话框函数应用于HTML结构中不存在的div,也没有在javascript / jquery中创建对话框函数。

So you must have an element with that id inside your html so you can call that dialog on it 因此,您必须在HTML中包含一个具有该ID的元素,以便您可以在其上调用该对话框

As you can see in the example on jQueryUI site https://jqueryui.com/dialog/ 如您在jQueryUI网站https://jqueryui.com/dialog/上的示例中所见

 $(document).ready(function() { $("#PDFdialog").dialog({ width: 500, autoOpen: false, resizable: false, draggable: false, modal: false, title: "pdf", buttons: [ { text: "Annuler", click: function() { $( this ).dialog( "close" ); } }] }); $("#pdfsub").click(function(){ $("#PDFdialog").dialog("open"); }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"/> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <input id="pdfsub" type="button" name="pdfsub" value="PDF"> <div id="PDFdialog"> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM