javascript - Simple Jquery Dialog but now on click - Stack Overflow

I tried making a dialog using jquery it works but I have no succes at doing it onclick bacuse it should

I tried making a dialog using jquery it works but I have no succes at doing it onclick bacuse it should not just popup but only when you click on it.

<script type="text/javascript"> 
$.ui.dialog.defaults.bgiframe = true;
$(function() {
    $("#dialog").dialog();
});
</script>  

and

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

and for the nice looking button

<button id="create-user" class="ui-button ui-state-default ui-corner-all">Profiel Matthijs</button>

tried using these examples

/

anyone know how to get this working with an click on the #create-user button i am not so good at javascript.

Thanks Matthy

I tried making a dialog using jquery it works but I have no succes at doing it onclick bacuse it should not just popup but only when you click on it.

<script type="text/javascript"> 
$.ui.dialog.defaults.bgiframe = true;
$(function() {
    $("#dialog").dialog();
});
</script>  

and

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

and for the nice looking button

<button id="create-user" class="ui-button ui-state-default ui-corner-all">Profiel Matthijs</button>

tried using these examples

http://jqueryui./demos/dialog/
http://jqueryui./demos/dialog/#modal-form

anyone know how to get this working with an click on the #create-user button i am not so good at javascript.

Thanks Matthy

Share Improve this question asked Jul 30, 2009 at 0:32 matthymatthy 8,34410 gold badges39 silver badges47 bronze badges 2
  • 1 "I have no succes at doing it onclick bacuse it should not just popup but only when you click on it." aren't both the same thing? When do you want your dialog box appear can you rephrase? – Sinan Commented Jul 30, 2009 at 0:37
  • ok understand what you mean, because you fire it at document ready function it popups when page loads... the answers are fair enough below i think then... – Sinan Commented Jul 30, 2009 at 0:40
Add a ment  | 

1 Answer 1

Reset to default 6

You need to set the autoOpen option to false so that the dialog will not open when its created.

To open it when your button is clicked, you would call the open method.

<script type="text/javascript"> 
    $.ui.dialog.defaults.bgiframe = true;
    $(function() {
        $('#dialog').dialog({
            autoOpen: false
        });
        $('#create-user').click(function() {
            $('#dialog').dialog('open');
        });
    });
</script>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743757283a4501986.html

相关推荐

  • javascript - Simple Jquery Dialog but now on click - Stack Overflow

    I tried making a dialog using jquery it works but I have no succes at doing it onclick bacuse it should

    6天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信