Reputation: 3156
My alert is reached and works, but the close method is not working. Any idea why ?
My javascript:
var myDialog = $('#divContactUs');
myDialog.dialog({
autoOpen: false,
title: "Send Us A Note:",
modal: true,
buttons: [{
id: "btn-send",
text: "Send",
click: function () {
// you can now use the reference to the dialog
myDialog.dialog("close");
alert('test');
}
}]
});
});
And my html:
<div id="divContactUs" style="display:none">
Name:   <input type="text" name="Name" /><br />
Email:   <input type="text" name="Email" /><br />
Phone:   <input type="text" name="Phone" /><br />
Message:<br />
<textarea name="Message"></textarea>
</div>
Upvotes: 2
Views: 6258
Reputation: 3572
Sometimes IE throws an error "Unspecified Error".
try{
$(selector).dialog("close");.
}catch(e){
$(selector).parent().hide();
}
Upvotes: 0
Reputation: 5419
You script is working. Don't forget to add semicolon ;
add the end of your lines $(this).dialog("close");
.
Here's a jsFiddle to prove it JsFiddle
Upvotes: 0
Reputation: 23250
In the scope of the button click $(this)
refers to the button, not the modal. I would set the modal selector to a variable first then reference it later;
var myDialog = $('#divContactUs');
myDialog.dialog({
autoOpen: false,
title: "Send Us A Note:",
modal: true,
buttons: [{
id:"btn-send",
text: "Send",
click: function() {
// you can now use the reference to the dialog
myDialog.dialog("close")
}
}
});
Upvotes: 2