- jQuery UI Dialog Will Not Close
- $(function () {
- $(".editLink").button();
- $('#editPersonDialog').dialog({
- autoOpen: false,
- width: 800,
- resizable: false,
- title: 'Edit Person',
- modal: true,
- buttons: {
- "Save": function () {
- $("#update-message").html('');
- $("#updatePersonForm").submit();
- },
- "Close": function () {
- $(this).dialog('close');
- }
- },
- close: function (event, ui) {
- $(this).dialog('close');
- }
- });
- $(".editLink").click(function () {
- var dialogDiv = $('#editPersonDialog');
- var linkObj = $(this);
- var viewUrl = linkObj.attr('href');
- $.get(viewUrl, function (data) {
- dialogDiv.html(data);
- //validation
- var $form = $("#updatePersonForm");
- // unbind existing validation
- $form.unbind();
- $form.data("validator", null);
- // check document for changes
- $.validator.unobtrusive.parse(document);
- // re-add validation with changes
- $form.validate($form.data("unobtrusiveValidation").options);
- // open dialog
- dialogDiv.dialog('open');
- });
- return false;
- });
- });
- function updateSuccess() {
- if ($("#update-message").html() == "True") {
- $('#editPersonDialog').dialog('close');
- $("#commonMessage").html("Update Complete");
- $("#commonMessage").delay(400).slideDown(400).delay(3000).slideUp(400);
- }
- else {
- $("#update-message").show();
- }
- }
- @using (Ajax.BeginForm("Edit", "Person", null,
- new AjaxOptions
- {
- UpdateTargetId = "update-message",
- InsertionMode = InsertionMode.Replace,
- HttpMethod = "POST",
- OnSuccess = "updateSuccess"
- },
- new { @id = "updatePersonForm" }))
- {
- @Html.ValidationSummary(true)
- <div id="update-message" class="hiddenDiv"></div>
- <div class="blockGraygradient">
- @Html.Partial("_CreateEditCommon")
- @Html.HiddenFor(model => model.SelectedPerson.Id)
- @Html.HiddenFor(model => model.SelectedPerson.RowVersion)
- @Html.HiddenFor(model => model.SelectedPerson.CreateTime)
- </div><p/>
- }
- $(this).dialog('destroy');
- $('#editPersonDialog').dialog({
- autoOpen: false,
- width: 800,
- resizable: false,
- title: 'Edit Person',
- modal: true,
- buttons: {
- "Save": function () {
- $("#update-message").html('');
- $("#updatePersonForm").submit();
- },
- "Close": function () {
- $(this).dialog('close');
- }
- }
- });