Jquery使面板可见后单击"不工作"
Jquery Click Not working After making Panel Visible
我在文本框后面的面板中有一个图像。在页面加载时,面板处于不可见状态。
在下拉列表中选择值后,面板将变为可见。
在面板变为可见之后,Jquery图像单击不起作用。
我正在使用UpdatePanel进行下拉列表回发,这会是原因吗?
如果没有,如何解决?
<tr>
<td colspan="2" class="invisible">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel runat="server" ID="pnlMonitor" Width="100%" Visible="false" CssClass="panelstyle" >
<table style="width: 100%">
<tr>
<td>Periodic Review Admin:<span style="color: red">*</span>
</td>
<td>
<asp:TextBox runat="server" ID="txtPeriodicReviewAdmin" CssClass="text ui-widget-content ui-corner-all" MaxLength="50"></asp:TextBox>
<img src="../Images/Binoculars.png" id="imgPRAdmin" />
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlMonitor" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
$("#imgPRAdmin").click(function (e) {
$("#divSearch").dialog({
open: function () {
$(this).closest(".ui-dialog")
.find(".ui-dialog-titlebar-close")
.removeClass("ui-dialog-titlebar-close");
},
title: "Search Employee",
show: "fade",
modal: true,
width: '55%',
height: 500
});
});
UpdatePanel
将替换DOM元素,因此click()
将只订阅原始DOM元素。当UpdatePanel用新项目刷新自己的内容时,它将替换DOM元素,并且它们不会有点击订阅。
您需要使用on
函数。在jQuery的早期版本中,它是live
,但后来它被弃用了
$("body").on('click', "#imgPRAdmin", function (e) {
$("#divSearch").dialog({
open: function () {
$(this).closest(".ui-dialog")
.find(".ui-dialog-titlebar-close")
.removeClass("ui-dialog-titlebar-close");
},
title: "Search Employee",
show: "fade",
modal: true,
width: '55%',
height: 500
});
});
您需要使用委派。更改此-
$("#imgPRAdmin").click(function (e) {
到这个-
$("body").on('click', '#imgPRAdmin', function (e) {
这解释了DOM树中冒泡的事件。
相关文章:
- Scriptaculous dom:仅加载工作"有时“;
- 我对“;返回true"嵌套函数内部;t工作
- Jquery scrollTop动画不工作"无法读取属性'top'无风
- "此网站似乎使用滚动链接定位效果.这可能不能很好地与异步平移一起工作;
- 无法使Nativescript插件工作"nativescript admob”;
- "npm运行构建:css"不能工作,而当我自己运行脚本时是可以的
- Django,HTML,JS:<img src=“#">可以在HTML中工作,但不能在JS文件中工作
- jQuery css"点击“;不会'更改日历中选定的月份后无法工作
- 无法调用方法“”;getEditResponseUrl"当使用表单ID打开表单时,绑定到工作表的Google
- "键“;jQuery中的对象无法正常工作
- 得到"标签“;标签在Internet Explorer 6中工作(用于单选按钮)
- 如何获得Facebook Like Box"黑暗方案”;正确工作?(背景是透明的.)
- 工作方法:document.getElementById(“ElementName”).style="显示:阻
- "点击“;不会'我不能在手机上工作
- 如何“;(M[key]||(M[key]=[])).push(elem)"工作
- "添加到购物车”;按钮不'由于ReferenceError,无法工作
- 如何"递归AJAX回调”;在JavaScript工作中
- 其中的行“xmlns:ng="http://angularjs.org"`工作/需要
- 如何使工作jquery"“滑动”;在iPad上滚动
- 像在PHP中一样,在jQuery中执行单引号(')和双引号(quot;)的工作