#8582 closed bug (duplicate)
.focus() fires attribute events, but doesn't fire binded events
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | 1.next |
Component: | unfiled | Version: | 1.5.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When a focus related event is binded to an element, it is fired when the element loses the focus via browser way (tab key, mouse click). But when it loses focus via .focus() to another element, it doesn't fire. However, if the event is defined on the attribute of the element, it fires in both cases.
I attach a complete test: Control1 fires change event when loses focus with mouse or tab key, but doesn't fire change event when pressing enter key (which executes a focus on #submitbutton). In the other hand, Control2 fires change event in both cases. I've tested this on jQuery 1.5.1 and 1.3.2 in the following browsers: Firefox 4, IE9 and Chrome, and there is the same issue.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>TESTING</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script> <script type="text/javascript" charset="UTF-8"> /* <![CDATA[ */ $(document).ready(function() { if ($.browser.mozilla) { $("input.data-entry").keypress (checkEnter); } else { $("input.data-entry").keydown (checkEnter); } $('#control1').bind('change', function(event){$('#result').html($(this).val());}); }); function checkEnter(event) { if (event.keyCode == 13) { $('#submitbutton').focus(); return false; } } /* ]]> */ </script> </head> <body> <form action="/" method="get"> <fieldset> <input type="text" id="control1" name="control1" value="control1" class="data-entry" tabindex="1" /><br /> <input type="text" id="control2" name="control2" value="control2" class="data-entry" tabindex="2" onchange="$('#result').html($(this).val());"/><br /> <div id="result">- - -</div><br /> <input type="submit" id="submitbutton" /> </fieldset> </form> </body> </html>
Change History (4)
comment:1 Changed 12 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 follow-up: 4 Changed 12 years ago by
comment:3 Changed 12 years ago by
I think that isn't the same issue, because it also happens with jQuery 1.4.2 and all the other jQuery versions. It seems to be a similar bug, not the same.
Duplicate of #7340.