This question is locked. New answers and comments are not allowed.
Hello. I am having a problem opening a modal prompt dialog and keeping it open. The window creation code is below and the prompt, which replaces the entire window with new content and opens it. What happens is that the dialog opens then quickly disappears. If I uncomment out the alert right before the open(), then it acts as it should. I have tried explicitly setting z-index and messing with css display attributes, but nothing alters this behavior. Any idea how to get this dialog to stick on its own?
MVC PartialView:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<OMS.Web.Models.JobViewModel>" %>
<%@ Import Namespace="OMS.Domain" %>
<% Html.Telerik().Window()
.Name("dlgAuditPrompt")
.Title("Job Change Audit")
.Icon("../../Content/new_window_16x16.png")
.Content(() =>
{ %>
<% Html.BeginForm("SaveAuditRecord", "Job");
{ %>
<div class="oms-inputLabel"><label for="Username">Name: </label><%= Html.TextBoxFor(x => x.AuditRecord.Username, new { @readonly = "readonly" })%></div>
<div class="oms-inputLabel"><label for="JobID">Job ID: </label><%= Html.TextBoxFor(x => x.AuditRecord.JobID, new { @readonly = "readonly" })%></div>
<div class="oms-inputLabel"><label for="Modification">Modification: </label><%= Html.TextAreaFor(x => x.AuditRecord.Modification, 10, 50, new { @readonly = "readonly" })%></div>
<div class="oms-inputLabel"><label for="Reason">Reason: </label><%= Html.TextAreaFor(x => x.Reason, 4, 50, new { id = "txtAuditReason" })%></div>
<br /><br />
<div><input id="SaveAuditRecord" type="submit" value="Save" /> <input type="button" value="Cancel" onclick="var window = $('#dlgAuditPrompt').data('tWindow');window.close();return false;"/></div>
<% Html.EndForm();
} %>
<% })
//.HtmlAttributes(new { style="z-index:1000000" })
.Draggable(true)
.Scrollable(false)
.Resizable()
.Width(490)
.Height(470)
.Visible(false)
.Modal(true)
.Render();
%>
Calling javascript:
function promptForAudit() {
$.ajax({
url: '/Job/SetAuditPromptData',
type: 'post',
data: $('#frmJob').serialize(),
dataType: 'html',
success: function (htmlData) {
//if you don't remove the dialog, you will never see the data is it will always be behind the uninitialized one
$('#dlgAuditPrompt').remove();
//use the partial view to replace the original
$('#AuditPromptDiv').html(htmlData);
}
});
//alert('Before you leave the page, you need to enter a reason for the changes you made. [Remove this]'); //NOTE: WITHOUT THIS DIALOG, THE PROMPT NEVER OPENS.
$('#dlgAuditPrompt').data('tWindow').center().open();
$('#txtAuditReason').focus();
}
Thanks,
Michael
MVC PartialView:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<OMS.Web.Models.JobViewModel>" %>
<%@ Import Namespace="OMS.Domain" %>
<% Html.Telerik().Window()
.Name("dlgAuditPrompt")
.Title("Job Change Audit")
.Icon("../../Content/new_window_16x16.png")
.Content(() =>
{ %>
<% Html.BeginForm("SaveAuditRecord", "Job");
{ %>
<div class="oms-inputLabel"><label for="Username">Name: </label><%= Html.TextBoxFor(x => x.AuditRecord.Username, new { @readonly = "readonly" })%></div>
<div class="oms-inputLabel"><label for="JobID">Job ID: </label><%= Html.TextBoxFor(x => x.AuditRecord.JobID, new { @readonly = "readonly" })%></div>
<div class="oms-inputLabel"><label for="Modification">Modification: </label><%= Html.TextAreaFor(x => x.AuditRecord.Modification, 10, 50, new { @readonly = "readonly" })%></div>
<div class="oms-inputLabel"><label for="Reason">Reason: </label><%= Html.TextAreaFor(x => x.Reason, 4, 50, new { id = "txtAuditReason" })%></div>
<br /><br />
<div><input id="SaveAuditRecord" type="submit" value="Save" /> <input type="button" value="Cancel" onclick="var window = $('#dlgAuditPrompt').data('tWindow');window.close();return false;"/></div>
<% Html.EndForm();
} %>
<% })
//.HtmlAttributes(new { style="z-index:1000000" })
.Draggable(true)
.Scrollable(false)
.Resizable()
.Width(490)
.Height(470)
.Visible(false)
.Modal(true)
.Render();
%>
Calling javascript:
function promptForAudit() {
$.ajax({
url: '/Job/SetAuditPromptData',
type: 'post',
data: $('#frmJob').serialize(),
dataType: 'html',
success: function (htmlData) {
//if you don't remove the dialog, you will never see the data is it will always be behind the uninitialized one
$('#dlgAuditPrompt').remove();
//use the partial view to replace the original
$('#AuditPromptDiv').html(htmlData);
}
});
//alert('Before you leave the page, you need to enter a reason for the changes you made. [Remove this]'); //NOTE: WITHOUT THIS DIALOG, THE PROMPT NEVER OPENS.
$('#dlgAuditPrompt').data('tWindow').center().open();
$('#txtAuditReason').focus();
}
Thanks,
Michael