[jQuery] jQuery and non-jQuery events
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<HTML><HEAD>
<META content="MSHTML 6.00.2900.3059" name=GENERATOR></HEAD>
<BODY leftMargin=1 topMargin=1 rightMargin=1><FONT
face=Tahoma size=2>
<DIV>Hi Mladen,</DIV>
<DIV> </DIV>
<DIV>This looks reminiscent of problems I've
been having the last few days with onclick=""
versus .click(fn) for setting the click event
for elements. My problem occurred in Firefox
and not IE.</DIV>
<DIV> </DIV>
<DIV>Bug report for mine is here: <A href="http://dev.jquery.com/ticket/1043#preview">http://dev.jquery.com/ticket/1043#preview</A></DIV>
<DIV> </DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV>HTH,</DIV>
<DIV>rob</DIV>
<DIV><BR><FONT color=blue>> Hi everybody,<BR><BR>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:<BR><BR><!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
<A href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><FONT
color=#0000ff>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></FONT></A>
<BR><html xmlns="http://www.w3.org/1999/xhtml"
><BR><head><BR> <title>Untitled
Page</title><BR><script type="text/javascript"
src="jquery.js"></script><BR><script
type="text/javascript"><BR><BR>$(function()
{ <BR> $('#btn1').click(<BR> function()
{<BR> alert('btn1
clicked');<BR> }<BR> );<BR> $('#btn3').click(<BR> function()
{<BR> alert('btn3
clicked');<BR> $('#btn1').click();
<BR> $('#btn1').get(0).onclick();<BR> $('#btn1').get(0).click();<BR> $('#btn2').click();<BR> $('#btn2').get(0).onclick();<BR> $('#btn2').get(0).click();
<BR> }<BR> );
<BR> <BR>}); <BR><BR>function
btn2Click() {<BR> alert('btn2
clicked');<BR>}<BR></script><BR></head><BR><body><BR> <input
type="button" id="btn1" value="btn1" />
<BR> <input type="button"
id="btn2" value="btn2" onclick="btn2Click()"
/> <BR> <input type="button"
id="btn3" value="btn3" /><BR></body><BR></html><BR><BR>The
same page could be found at:<BR><BR><A href="http://radioni.ca/jquery-click.html"><FONT
color=#0000ff>http://radioni.ca/jquery-click.html</FONT></A><BR><BR>so
you can try it out yourselves.<BR><BR>Click
on the third button causes following alerts
to be displayed: <BR>* 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) <BR><BR>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.<BR><BR>______________________________________________________________________<BR>This
email has been scanned by the MessageLabs
Email Security System.<BR>For more information
please visit <A href="http://www.messagelabs.com/email"><FONT
color=#0000ff>http://www.messagelabs.com/email</FONT></A>
<BR>______________________________________________________________________<BR><<BR></DIV></FONT></FONT>
<DIV style="FONT-SIZE: x-small; FONT-FAMILY:
Tahoma">
<DIV>----------------------- <B>Original
Message</B> -----------------------</DIV>
<DIV> </DIV>
<DIV><B>From:</B> "Mladen Jablanovic"
<A href="mailto:jablan@gmail.com"><FONT color=#0000ff><jablan@gmail.com></FONT></A></DIV>
<DIV><B>To:</B> <A href="mailto:discuss@jquery.com"><FONT
color=#0000ff>discuss@jquery.com</FONT></A></DIV>
<DIV><B>Date:</B> Thu, 15 Mar 2007 15:59:08
+0100</DIV>
<DIV><B>Subject: <U>[jQuery] jQuery
and non-jQuery events</U></B></DIV>
<DIV> </DIV></DIV>Hi everybody,<BR><BR>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:<BR><BR><SPAN style="FONT-FAMILY:
courier new,monospace"><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"<A href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</A>"></SPAN>
<BR style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace"><html
xmlns="<A href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</A>"
></SPAN><BR style="FONT-FAMILY: courier
new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace"><head></SPAN><BR
style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace">
<title>Untitled Page</title></SPAN><BR
style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace"><script
type="text/javascript" src="jquery.js"></script></SPAN><BR
style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace"><script
type="text/javascript"></SPAN><BR style="FONT-FAMILY:
courier new,monospace"><BR style="FONT-FAMILY:
courier new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace">$(function() {</SPAN>
<BR style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace">
$('#btn1').click(</SPAN><BR style="FONT-FAMILY:
courier new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace">
function() {</SPAN><BR
style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace">
alert('btn1
clicked');</SPAN><BR style="FONT-FAMILY:
courier new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace">
}</SPAN><BR style="FONT-FAMILY:
courier new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace">
);</SPAN><BR style="FONT-FAMILY: courier
new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace">
$('#btn3').click(</SPAN><BR style="FONT-FAMILY:
courier new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace">
function() {</SPAN><BR
style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace">
alert('btn3
clicked');</SPAN><BR style="FONT-FAMILY:
courier new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace">
$('#btn1').click();
</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace">
$('#btn1').get(0).onclick();</SPAN><BR
style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace">
$('#btn1').get(0).click();</SPAN><BR
style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace">
$('#btn2').click();</SPAN><BR
style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace">
$('#btn2').get(0).onclick();</SPAN><BR
style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace">
$('#btn2').get(0).click();
</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace">
}</SPAN><BR style="FONT-FAMILY:
courier new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace">
); </SPAN><BR style="FONT-FAMILY: courier
new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace">
</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace">});</SPAN>
<BR style="FONT-FAMILY: courier new,monospace"><BR
style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace">function
btn2Click() {</SPAN><BR style="FONT-FAMILY:
courier new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace">
alert('btn2 clicked');</SPAN><BR style="FONT-FAMILY:
courier new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace">}</SPAN><BR style="FONT-FAMILY:
courier new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace"></script></SPAN><BR
style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace"></head></SPAN><BR
style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace"><body></SPAN><BR
style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace">
<input type="button" id="btn1" value="btn1"
/> </SPAN><BR style="FONT-FAMILY: courier
new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace">
<input type="button" id="btn2" value="btn2"
onclick="btn2Click()" /> </SPAN><BR style="FONT-FAMILY:
courier new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace">
<input type="button" id="btn3" value="btn3"
/></SPAN><BR style="FONT-FAMILY: courier
new,monospace"><SPAN style="FONT-FAMILY:
courier new,monospace"></body></SPAN><BR
style="FONT-FAMILY: courier new,monospace"><SPAN
style="FONT-FAMILY: courier new,monospace"></html></SPAN><BR
style="FONT-FAMILY: courier new,monospace"><BR>The
same page could be found at:<BR><BR><A href="http://radioni.ca/jquery-click.html">http://radioni.ca/jquery-click.html</A><BR><BR>so
you can try it out yourselves.<BR><BR>Click
on the third button causes following alerts
to be displayed: <BR>
<OL>
<LI>btn3 clicked
<LI>btn1 clicked
<LI>btn1 clicked
<LI>btn2 clicked
<LI>btn2 clicked
<LI>btn2 clicked
<LI>btn2 clicked</LI></OL>Why 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)
<BR><BR>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.<BR><BR>______________________________________________________________________<BR>This
email has been scanned by the MessageLabs
Email Security System.<BR>For more information
please visit http://www.messagelabs.com/email
<BR>______________________________________________________________________<BR>
<STYLE type=text/css> P, UL, OL, DL, DIR,
MENU, PRE { margin: 0 auto;}</STYLE>
<FONT face=Tahoma size=2>
<DIV>_______________________________________________<BR>jQuery
mailing list<BR>discuss@jquery.com<BR>http://jquery.com/discuss/<BR><BR><BR></DIV></FONT>
<BR>
______________________________________________________________________<BR>
This email has been scanned by the MessageLabs Email Security System.<BR>
For more information please visit http://www.messagelabs.com/email <BR>
______________________________________________________________________<BR>
</BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/