-
Notifications
You must be signed in to change notification settings - Fork 20.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
triggering focus event with namespace runs all focus listeners #1750
Comments
Comment author: dmethvin This is another result of triggering the native focus event so we can get the event order right. There are no jQuery extensions (namespaces, data) in those cases. See #13428. |
Comment author: gibson042 Third time's the charm... https://github.com/jquery/jquery/pull/1367 |
Related: #1735 |
This might be an acceptable workaround to prevent firing the handler twice as mentioned in #1741 (comment): var $x = $("#aninput");
$x.triggerHandler("focus.myevent", ['extra', 'data']);
$x[0].focus();
$x.on("focus.myevent", function (e, extra, data) {
if (e.originalEvent) return;
console.log(extra, data);
});
$x.on("focus.notfired", function (e, extra, data) {
if (e.originalEvent) return;
console.log("This won't be fired.");
}); |
Fixed by 669f720: http://jsfiddle.net/3nwhq0o7/1/ |
Originally reported by peter@… at: http://bugs.jquery.com/ticket/14359
Using jQuery 1.9 onwards, calling .trigger('focus.myevent') focusses the target element and triggers all "focus" handlers, regardless of namespace.
This is inconsistent with other events, where only handlers with the "myevent" namespace would be triggered.
http://jsfiddle.net/PeterChaplin/GUSN5/
This behaviour does not appear to be present in 1.7.2 or 1.8.3.
I have only tested this on Google Chrome Version 29.0.1547.66 m, in Windows 7
Issue reported for jQuery 1.10.2
The text was updated successfully, but these errors were encountered: