Reputation: 9963
I have a jquery dialog box that I am having a few problems with. If I press the button "my-button" the dialog opens ok, however if I try pressing the close button I get an error "Error: $("#dialog").dialog is not a function"
Can anyone see what I am doing wrong in my script?
<script type="text/javascript">
$(function () {
$('#dialog').dialog({
autoOpen: false,
width: 600,
position: ["center", 200],
resizable: false,
title: 'Create Call',
modal: true,
open: function(event, ui) {
$(this).load("@Url.Action("CreateContactPartial")");
},
buttons: {
"Enter":function () {
alert('pressed');
},
"Close": function () {
$(this).dialog('close');
return false;
}
}
});
$('#my-button').click(function () {
$('#dialog').dialog('open');
return false;
});
});
Upvotes: 0
Views: 388
Reputation: 4683
try to use this
window.parent.$(this).dialog('close');
or
window.$(this).dialog('close');
Upvotes: 0
Reputation: 14435
I created a jsfiddle and got the close button to work: http://jsfiddle.net/x45hD/
I changed this:
$(this).load("@Url.Action('CreateContactPartial')");
But, I'm not sure if that is the cause.
Upvotes: 1