Skip to content
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

Should .trigger() more clearly indicate that it does not invoke event listeners created outside of jQuery? #1191

Open
NReilingh opened this issue May 26, 2021 · 1 comment

Comments

@NReilingh
Copy link

I have been using jQuery for about 9 years, and only just today did I realize that $('#element').trigger('change'); is not equivalent to $('#element')[0].dispatchEvent(new Event('change'));.

On a careful reading of https://api.jquery.com/trigger/, it does indicate:

Any event handlers attached with .on() or one of its shortcut methods are triggered...

However, I wonder if there should be a more explicit callout that listeners for event types added via EventTarget.addEventListener() are not invoked.

I believe I had my incorrect expectation because I did not realized there was a semantic difference between a DOM EventListener and a jQuery event handler, and because I was already used to using jQuery as a sort of friendly, cross-browser interface for other Web APIs (Noting that new Event() never received support in IE, for example).

@NReilingh
Copy link
Author

This Learn article has some useful information, but I never came across it before finding a link to it in a different issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant