Simple Jquery Dialog but now on click
23,288
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>
Author by
matthy
Updated on July 30, 2020Comments
-
matthy almost 4 years
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-formanyone know how to get this working with an click on the #create-user button i am not so good at javascript.
Thanks Matthy