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
Adding the useOnlyNativeEvents (was: preferJQueryEvents) option as a way to avoid using jquery eventing in knockout. #1774
Adding the useOnlyNativeEvents (was: preferJQueryEvents) option as a way to avoid using jquery eventing in knockout. #1774
Conversation
Thanks for this! Is it possible to add a test for this change? When we run the tests, we do so both with and without jQuery, so it would make sense to have a test that we don't get jQuery event behaviour in the presence of this flag. |
Should this option also affect |
I'll look into the tests. Good call @mbest. I will take a look. |
Added a test to validate the option locks out jquery eventing. Updated trigger. I ran this with runner.html and runner.html?jquery=1, and validated it works in both cases. I'm not sure of a clever way to distinguish trigger behavior coming from jquery vs not. |
ping! |
It's better to use direct terminology. I'd like to see At least it's hard to understand for my brain the meaning of |
I agree with @stalniy – The double-negative is too much for my brain. :) The one caveat is that when |
Renamed to "useJQueryEventing". Hmm. Maybe it should be "useJQueryEventingWhenAvailable"... or "allowJQueryEventing" or "allowJQueryEventingOverride", or maybe even a more general "allowJQueryOverrides" even though it only affects eventing... ? |
When I was reading your comment, I at first thought it said "everything" instead of "eventing". |
Happy to rename, just give me something everyone is satisified with, so we can finish this off. I can change to useJqueryEvents if it is more straightforward. In my opinion options are always going to be a little mysterious to use, even if named something completely innocent, so naming it useJQueryEvents vs useJqueryEventsWhenAvailable is still going to require a little digging to understand what that implies. It requires a little digging just to even know that jQuery is being referenced from knockout in the first place, I would have not guessed that. |
@dzearing How does |
Done, I like it. |
Any other feedback? |
…ption Adding the preferJQueryEvents option as a way to avoid using jquery eventing in knockout.
Looks great! And thanks for making the option name change - sounds ideal now. Merged. I think the other core team members will have seen this by now (since @mbest and @brianmhunt have commented here) but if not and any of you have concerns please let us know. |
I thought that this one seemed fine. I would generally prefer new options to match the default/current behavior when undefined/falsey, but did agree that the double-negative was confusing. |
If we'd rather have an option that defaults to |
+1 |
Note: option was updated to |
@rniemeyer I updated the title too, just in case someone wanders onto this :) |
Usage:
// Now all events fired from knockout should not have jquery in the callstack. It is assumed the option is set before applyBindings is called.