弹出窗口不能正确加载.它需要每次刷新页面
Pop-up does not load correctly. It needs page refresh every time
有一个链接:
<div >
<a href="#" class="newComment" onclick="bindAddSlots()">Add Details</a>
</div>
onclick
方法:
function bindAddSlots() {
debugger;
if (!CheckforLogout()) {
return false;
}
ClearPopUpControls();
var dclg;
dclg = $("#dvSchedulingProfile").dialog(
{
resizable: false,
draggable: true,
modal: true,
title: "ADD Details",
width: "400",
height: "460"
});
dclg.parent().appendTo(jQuery("form:first"));
}
function ClearPopUpControls() {
debugger;
$("#ddlVisitType").val("Select Options");
$("#SchedulingProfileDetails_Id").val("0");
$("#dvSchedulingProfile").find("#txtNP").val("");
$("#dvSchedulingProfile").find("#txtNS").val("");
$("#dvSchedulingProfile").find(".lblAnnualVisitType").hide();
$("#dvSchedulingProfile").find(".lblNP").hide();
$("#dvSchedulingProfile").find(".lblNS").hide();
$("#dvSchedulingProfile").find(".lblNPNumeric").hide();
$("#dvSchedulingProfile").find(".lblNSNumeric").hide();
$("#SchedulingProfileDetails_Id").val("0");
}
视图代码:
<div id="dvSchedulingProfile" style="display: none">
@Html.ValidationSummary(true)
<table width="100%" height="75%" class="someclass">
<tr id="AddVisitType">
<td class="black_label">
@Html.HiddenFor(m => m.SchedulingProfileDetails.Id)
@Html.Label("Visit Type"):<span class="star">*</span>
</td>
<td style="font-size: 12px;">
@Html.DropDownList("ddlVisitType", new SelectList((VisitTypeBo.LoadAll().OrderBy(x => x.VisitTypeName)), "VisitTypeName", "VisitTypeName"), new { @style = "width:250px;color:black" })
<br/>
</td>
</tr>
<tr>
<td height="5">
</td>
<td style="color: Red; font-size: 12px; display: none;" class="lblAnnualVisitType"
align="left">
@Html.Label("lblAnnualVisitType", "Visit Type is required.")
</td>
</tr>
<tr>
<td height="5">
</td>
</tr>
<tr>
<td class="black_label">
@Html.Label("Patient Slots(NP)"):<span class="star">*</span>
</td>
<td style="font-size: 12px;">
@Html.TextBox("txtNP", null, new { @style = "width:250px;", maxlength = 11 })
</td>
</tr>
<tr>
<td height="5">
</td>
<td style="color: Red; font-size: 12px; display: none;" class="lblNP" align="left">
@Html.Label("lblNP", "NP is required.")
</td>
<td style="color: Red; font-size: 12px; display: none;" class="lblNPNumeric" align="left">
@Html.Label("lblNPNumeric", "Only Numeric values are allowed.")
</td>
</tr>
<tr>
<td class="black_label">
@Html.Label("Time Slots(NS)"):<span class="star">*</span>
</td>
<td style="font-size: 12px;">
@Html.TextBox("txtNS", null, new { @style = "width:250px;", maxlength = 11 })
</td>
</tr>
<tr>
<td height="5">
</td>
<td style="color: Red; font-size: 12px; display: none;" class="lblNS" align="left">
@Html.Label("lblNS", "NS is required.")
</td>
<td style="color: Red; font-size: 12px; display: none;" class="lblNSNumeric" align="left">
@Html.Label("lblNSNumeric", "Only Numeric values are allowed.")
</td>
</tr>
<tr>
<td height="5">
</td>
</tr>
<tr>
<td>
</td>
<td >
<input type="button" value="" class="save_bt" onclick="return SaveDetails()" style="margin-left:70PX;"/>
</td>
</tr>
</table>
</div>
现在的问题是,当页面加载,我点击弹出窗口的链接,但弹出窗口出来了,我需要刷新代码,问题是相同的,在所有的浏览器。我一次又一次地调试代码,但没有错误的到来,我完全困惑,所以有人请帮助我克服这个问题。
究竟需要将对话框附加到表单的第一个元素上吗?如果你去掉那条线,我想应该没问题。
因为,第一次它工作正常,因为只有一个元素与id dvSchedulingProfile
和立即显示对话框后,你添加相同的元素再次到表单的第一个元素,所以下次有两个元素具有相同的id,现在jquery对话框不工作,因为它不会找到一个单一的元素与给定的id..
问题是,当我们关闭对话框时,它只是关闭的,但我们需要销毁它,这样表单就没有任何剩余的关联。因此,我们需要一些额外的代码行来决定当我们关闭弹出窗口时要做什么。
var dclg=$("#dvSchedulingProfile")
dclg.dialog(
{
resizable: false,
draggable: true,
modal: true,
title: "ADD Details",
width: "400",
height: "460",
close: function () {
dclg.dialog("destroy");
dclg.hide();
}
});
相关文章:
- 刷新父窗口后无法关闭窗口
- 如何使用javascript刷新父页面并关闭子窗口
- 关闭弹出窗口并刷新父页面
- 检测window.opener窗口刷新事件
- 关闭弹出窗口并刷新父页面javascript
- 只有当选项卡/窗口有焦点时,页面才能每5秒刷新一次
- 在jQuery中的IFrame中提交表单后刷新父窗口
- 如何在提交后关闭颜色框窗口,并刷新父页面上的图像
- ColdFusion.Window.create不刷新弹出窗口
- 弹出窗口中的内容不会刷新.如何使动态
- 在调整窗口大小时刷新浏览器(仅在展开或放大时)
- j查询模式窗口,刷新父问题
- 如何在弹出窗口关闭后刷新(回发)aspx 页
- 刷新窗口后,下拉列表未保持选中状态
- 刷新窗口时获取URL;不适用于Chrome扩展
- 在JavaScript中不刷新窗口焦点
- 自动刷新窗口
- 我如何使这个响应(刷新窗口大小)Raphaeljs
- IE 9不使用window.open刷新窗口,而是打开新窗口
- url更改时刷新窗口- AngularJS