Simple Jquery Dialog but now on click

dialog, html, javascript, jquery, onclick

Solution

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>

Problem

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.com/demos/dialog/ http://jqueryui.com/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

Original source