Further to my last email regarding unbind("foo") not being able to remove events set in the HTML "onfoo" attribute, is another problem which is harder to work around.
Using two functions to handle the click event for a button, each function swapping the handler to the other. (Ignore that this can be done with toggle(), this is a simplified test script.) Behaviour is different in Firefox2.0.0.2 and IE6.0. In FF, the test runs as follows for each click: 1. alerts "tested 4.1" as expected 2. alerts "tested 4.1" then alerts "tested 4.2" 3. alerts "tested 4.1" as expected Each click after this runs as expected. In IE6.0, the test runs as follows: 1. alerts "tested 4.1" as expected 2. alerts "tested 4.2" then alerts "tested 4.1" Each click after this runs the same as the 2nd. What's even more odd is that if the final line running .click() in Test4_1() or Test_2() is commented out, everything also behaves as expected. I'll file this as soon as the bug-reporter stops telling me the the database is locked; in the meantime can anyone check to make sure it's not me being stupid, or suggest a workaround? Thanks all! This is the test page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv='content-type' content='text/html; charset=ISO-8859-1' /> <title>Tester</title> <script src='/jquery.js' type='text/javascript'></script> <script type='text/javascript'><!-- function test4_1() { alert('tested 4.1'); $("#testButton4").removeAttr("onclick"); $("#testButton4").unbind("click"); $("#testButton4").html("Test 4.2"); $("#testButton4").click(test4_2); } function test4_2() { alert('tested 4.2'); $("#testButton4").removeAttr("onclick"); $("#testButton4").unbind("click"); $("#testButton4").html("Test 4.1"); $("#testButton4").click(test4_1); } // --></script> </head> <body> <p style='background:red'>Uses removeAttr() and unbind(), then click() to rebind as it toggles between two tests <button id="testButton4" onclick="test4_1()">Test 4.1</button></p> </body> </html> --rob ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/