简体   繁体   English

在可见设置为false的控件上绑定Jquery事件

[英]Bind Jquery event on controls that have visible set to false

I have a GridView which is inside a Panel control.Panel is initially set to Visible="False" .I want to bind some JQuery Event on GridView control like- 我在Panel控件内有一个GridView。Panel最初设置为Visible="False" 。我想在GridView控件上绑定一些JQuery事件,例如-

$('#<%=Grd.ClientID%>').click(function(){ //Do some stuff }); $('#<%= Grd.ClientID%>')。click(function(){//做点事});

But Event is not binding due the Visibility of the Control. 但是由于控件的可见性,所以事件没有约束力。

Is there any way to so? 有什么办法吗?

Use event delegation: 使用事件委托:

$(document).on('click', '#<%=Grd.ClientID%>', function() {
    //...
});

See the Direct and delegated events section of the on() documentation . 请参阅on()文档的“ 直接和委托事件”部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM