Reputation: 7472
I have the following script:
<script type="text/javascript">
$( "#addLocation" ).dialog({
autoOpen: false,
modal: true,
height: 700,
width: 550,
buttons: {
"Add Location": function() {
document.forms["mapform"].submit();
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
});
</script>
<script type="text/javascript">
function showLocationDialog() {
$("#addLocation").dialog("open");
}
</script>
<div id="addLocation" style="display:none;">
<form action="" method="post" name="mapform">
<input type="text" name="name" />
<input type="submit" />
</form>
</div>
<button onclick="javascript:showLocationDialog();">Add an address</button>
The button does not open the dialog and I cannot understand why.. can anyone assist?
Thanks,
Upvotes: 1
Views: 1856
Reputation: 9234
another thing to try...
remove the display:none
css from the addLocation div..the dialog will take care of hiding everything once its initialized on document.ready
Upvotes: 0
Reputation: 45525
Wait for the DOM to be ready.
Stick your .dialog()
code in a $(document).ready()
or $()
block
Upvotes: 3
Reputation: 342635
1 - Put the .dialog()
initialization into a $(document).ready() { ... });
.
2 - Remove the extra comma from after the buttons value:
buttons: {
"Add Location": function() {
document.forms["mapform"].submit();
},
Cancel: function() {
$( this ).dialog( "close" );
}
}, <-- remove this, causes IE to spontaneously combust
Upvotes: 1