Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
106
rated 0 times [  109] [ 3]  / answers: 1 / hits: 23486  / 15 Years ago, thu, july 30, 2009, 12:00:00

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


More From » jquery

 Answers
60

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>

[#99031] Saturday, July 25, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jeremiahianx

Total Points: 629
Total Questions: 106
Total Answers: 112

Location: Djibouti
Member since Sun, Feb 27, 2022
2 Years ago
;