|
Hi Mladen,
This looks reminiscent of problems I've
been having the last few days with
versus .click(fn) for setting the click event
for elements. My problem occurred in Firefox
and not IE.
Bug report for mine is here: http://dev.jquery.com/ticket/1043#preview
I was trying to change the click handler
at runtime for elements whose original handlers
were set with the onclick attribute, the
only way I foudn to prevent the fault was
not to use that and to only use $("...").click(fn)
instead.
HTH,
rob
> Hi everybody, I would be very grateful if someone could explain to me behaviour of the following simple piece of code, which is from my perspective a bit strange: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Untitled Page</title> <script type="text/_javascript_" src=""></script> <script type="text/_javascript_"> $(function() { $('#btn1').click( function() { alert('btn1 clicked'); } ); $('#btn3').click( function() { alert('btn3 clicked'); $('#btn1').click(); $('#btn1').get(0).onclick(); $('#btn1').get(0).click(); $('#btn2').click(); $('#btn2').get(0).onclick(); $('#btn2').get(0).click(); } ); }); function btn2Click() { alert('btn2 clicked'); } </script> </head> <body> <input type="button" id="btn1" value="btn1" /> <input type="button" id="btn2" value="btn2" /> <input type="button" id="btn3" value="btn3" /> </body> </html> The same page could be found at: http://radioni.ca/jquery-click.html so you can try it out yourselves. Click on the third button causes following alerts to be displayed: * btn3 clicked* btn1 clicked* btn1 clicked* btn2 clicked* btn2 clicked* btn2 clicked* btn2 clickedWhy btn1 only twice, and btn2 even four times? (Note: is behaviour from Firefox, seems like IE behaves slightly different. Let's stay with FF for some time) Thanks in advance, I am not asking this just for fun, I have problems with submit event and I have created this code to simplify and illustrate. ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ < ----------------------- Original
Message -----------------------
From: "Mladen Jablanovic"
<[EMAIL PROTECTED]>
Date: Thu, 15 Mar 2007 15:59:08
+0100
Subject: [jQuery] jQuery
and non-jQuery events
I would be very grateful if someone could explain to me behaviour of the following simple piece of code, which is from my perspective a bit strange: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Untitled Page</title> <script type="text/_javascript_" src=""></script> <script type="text/_javascript_"> $(function() { $('#btn1').click( function() { alert('btn1 clicked'); } ); $('#btn3').click( function() { alert('btn3 clicked'); $('#btn1').click(); $('#btn1').get(0).onclick(); $('#btn1').get(0).click(); $('#btn2').click(); $('#btn2').get(0).onclick(); $('#btn2').get(0).click(); } ); }); function btn2Click() { alert('btn2 clicked'); } </script> </head> <body> <input type="button" id="btn1" value="btn1" /> <input type="button" id="btn2" value="btn2" /> <input type="button" id="btn3" value="btn3" /> </body> </html> The same page could be found at: http://radioni.ca/jquery-click.html so you can try it out yourselves. Click on the third button causes following alerts to be displayed:
Thanks in advance, I am not asking this just for fun, I have problems with submit event and I have created this code to simplify and illustrate. ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ _______________________________________________
jQuery mailing list [email protected] http://jquery.com/discuss/ ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
_______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/
