I have a button in my HTML, once click on the button, I want to open a JQuery Dialog. I have a version of code which works fine, but I just want to reorganize the code, seems like there's something wrong with it since the dialog cannot be displayed anymore.
the version that works:
<script type="text/javascript">
$(function() {
$('#dialog_trigger').on("click", function() {
$('#dialog').load('index.php', function() {
$('#dialog').dialog({
*********(somehow I must remove 'autoOpen: false' here, otherwise it also stops working) ********
position: 'center',
width : 480,
height : 320,
modal : true
});
});
});
});
</script>
<body>
<button id="dialog_trigger">Click me</button>
<div id="dialog"></div>
</body>
the code that doesn't work:
<script type="text/javascript">
$(function() {
$('#dialog_trigger').on("click", function() {
$('#dialog').load('index.php', function() {
$('#dialog').dialog("open")
});
});
$('#dialog').dialog({
autoOpen: false,
position: 'center',
width : 480,
height : 320,
modal : true
});
});
</script>
<body>
<button id="dialog_trigger">Click me</button>
<div id="dialog"></div>
</body>
Please help me correct it, thanks.
$('#dialog').dialog("")I don't think that's right, what are you really trying to do there?