Trigger element's onclick method with JQuery [ASP.NET]
- by blu
I have an ASP.NET server control that inherits from CheckBoxList that renders the controls with a UL and LIs. The control is set to AutoPostBack.
Markup:
<div id="foo">
<ul>
<li>
<input type="checkbox"
onclick="javascript:setTimeout('__doPostBack(..."
... />
<label ... />
</li>
</ul>
</div>
I would like to trigger the JavaScript that is rendered on the CheckBox when the parent LI is clicked. Here is what I have so far:
$("#foo li").click(function() {
$(this).find("input:eq(0)").trigger("click");
});
This fires a postback in FF 3.x but the event handler in the codebehind is not fired. In IE 7 a script error comes up and the browser just kind of hangs there for a bit then reloads the page.
How should I be doing this?