开发者

jQuery .click() and ModalPopupExtender

开发者 https://www.devze.com 2023-03-27 14:39 出处:网络
On my ASP.NET Web Forms page, there is a Panel which is a modal popup (using ModalPopupExtender in the AJAX Control Toolkit). Apparently, the jQuery .click(f) method does not work if the target contro

On my ASP.NET Web Forms page, there is a Panel which is a modal popup (using ModalPopupExtender in the AJAX Control Toolkit). Apparently, the jQuery .click(f) method does not work if the target control is in a popup. The following code works only if I move the CheckBox out of the popup:

$("#checkBox").click(function() {
  // do something
});

This is how the checkbox is declared on the server site:

<asp:CheckBox runat="server" ID="checkBox" Text="..." ClientIDMode="Static" />

I need to bind a handler to the checkbox, while in the panel. Does anybody habe a hint for me?

开发者_运维百科

Matthias


I don't know how the popups are implemented within the AJAX Control toolkit, but I suspect that the controls are added to the popup dynamically. If that is the case, you should do this (assuming you're not using an outdated version of jQuery):

$("#checkBox").live('click', function() {
  // do something
});

(See here to understand how this works.)

Try that and see if it works. If you're stuck with an old version of jQuery, I recommend using the LiveQuery plugin.

0

精彩评论

暂无评论...
验证码 换一张
取 消