简体   繁体   English

单击按钮时显示对话框

[英]display a dialog when i click a button

i ty to display a dialog when i click on a button 单击按钮时显示对话框

in my js part i have 在我的js部分中

   $('#dialog').dialog({
        autoOpen: false
    });

    $('#create-report').click(function() {
        $('#dialog').dialog('open');
    });

in my html part i have 在我的html部分中

<div id="dialog" title="Basic dialog" style="visibility:hidden;">
    <p>hi how are you</p>
</div>

<button id="create-report" >Create new report</button>

nothing is displayed and i don't have any error 什么都没有显示,我没有任何错误

why? 为什么?

Try using display:none instead of visibility:hidden to initially hide the dialog. 尝试使用display:none而不是visibility:hidden最初隐藏对话框。

<div id="dialog" title="Basic dialog" style="display:none;">
    <p>hi how are you</p>
</div>

Also make sure that jQuery and jQuery UI are being loaded properly. 还要确保正确加载了jQuery和jQuery UI。 This fiddle works: http://jsfiddle.net/E3Pek/ 这个小提琴有效: http : //jsfiddle.net/E3Pek/

It's not necessary that you put the style on your div. 不必将样式放在div上。

Should be like this: 应该是这样的:

<div id="dialog" title="Basic dialog">
    <p>hi how are you</p>
</div>

Remember the order that you have to load the jquery scripts. 记住您必须加载jquery脚本的顺序。 First load jquery library and then jquery-ui. 首先加载jquery库,然后加载jquery-ui。

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

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