Side navigation
#6508 closed bug (invalid)
Opened May 01, 2010 02:17AM UTC
Closed October 02, 2010 07:43PM UTC
Inadvertent change event firing on IE8
Reported by: | sharo | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.4.3 |
Component: | event | Version: | 1.4.2 |
Keywords: | onchange, live, event | Cc: | |
Blocked by: | Blocking: |
Description
I have found a scenario where the live function causes a re-firing of events on an unrelated element. I have put a sample page that shows this problem below.
It is quite simple to reproduce. First create two select elements. On Select1 place an inline onchange handler that simply does "alert('select1')".
On select2, add a class= "select2". Then use the live function to bind the change event to the select2 class:
$(".select2").live("change", function(){ alert("select2");})
As you change the value of each select, you would expect an alert to fire once each time the value changes on either select.
However if you change the value of select1 you will see two alerts.
If you give the live function a context this problem goes away.
###############################
# Sample Code
###############################
#!text/html <!DOCTYPE html> <html> <head> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <meta charset=utf-8 /> <title>JS Bin</title> <script> $(function() { $(".livecaller").live('change', function() { alert(1);}); }); </script> </head> <body> <form action="#"> <select onchange="alert(0);"> <option val="1">1</option> <option val="2">2</option> <option val="3">3</option> </select> <div id="foobar"> <select class="livecaller"> <option val="1">1</option> <option val="2">2</option> <option val="3">3</option> </select> </div> <input type=submit /> </form> </body> </html>
Attachments (0)
Change History (1)
Changed October 02, 2010 07:43PM UTC by comment:1
need: | Review → Test Case |
---|---|
priority: | → undecided |
resolution: | → invalid |
status: | new → closed |
Tested in IE 7, 8 and 9. I haven't experienced multiple alerts when selecting 'select1' in either of these.
Please re-submit with more details of the problem or with an alternative test case.