Hello,
I'm hoping someone might be able to offer some insight into a rather urgent issue I'm struggling with. I'm using jQuery in an ASP.NET application, and upon upgrading from jQuery 1.0.1 to 1.0.3, all my LinkButton controls throw an error ("event has no properties") when clicked. I've tracked it down to the fact that in 1.0.1, jQuery.event.fix does a null check on event before attaching the preventDefault function, whereas 1.0.3 does not do this check:

if ( event ) {
    event.preventDefault = function() {
        this.returnValue = false;
    };

If you can stop me at this point and say it's a know issue and there's a fix, great! Otherwise, here's my best attempt at explaining the situation, and maybe there's a workaround.

I *think* the problem has to do with some conflict between jQuery's event binding and the way ASP.NET submits a form from within a script. When these 2 conditions exist, jQuery.event.handle is being called with a null event, and I'm not sure why. If you're not familiar with ASP.NET, a LinkButton control is basically an abstraction of a hyperlink that causes a form post via _javascript_. The ASP.NET framework renders the following script, and the LinkButton's href calls __doPostBack:

<script type="text/_javascript_">
<!--
var theForm = document.forms['aspnetForm'];
if (!theForm) {
 theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
 if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
 theForm.__EVENTTARGET.value = eventTarget;
 theForm.__EVENTARGUMENT.value = eventArgument;
 theForm.submit();
 }
}
// -->
</script>

I also have a script that binds to the form submission as follows:

$('#aspnetForm').submit(function() {
    // doesn't matter what's here
});

It's the existence of the event binding above, combined with clicking on a LinkButton, that causes the error. And again, there were no issues in 1.0.1 due the null check.

Thanks for any help!
Todd

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to