-
Notifications
You must be signed in to change notification settings - Fork 506
Don't fire ajaxyness if "data-remote"="false" #339
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
Don't fire ajaxyness if "data-remote"="false" #339
Conversation
|
I think I'd rather stick with the principle of least surprise here. When you have HTML5 data attributes (or really just any attributes in general), there's no such thing as a That being said, I see the value, and I think I'd be fine with it if there weren't another really easy way to accomplish this already. Instead of using - @links.each do |link|
= link_to link.name, link.href, remote: link.remote?It's actually shorter and easier than what you have. If you use the built-in rails helper, it's smart enough to exclude the |
|
@JangoSteve thanks for the reply. The principle of least surprise is the thing urged me to send this pull request. And as of I can add that the app I'm working on toggles But I hope that the 2nd paragraph is quite powerful argument :) Regards, |
|
Just to be clear - @JangoSteve's expectations (from the linked discussion): <a data-remote></a> <!-- old behavior, link is remote -->
<a data-remote=true></a> <!-- old behavior, link is remote -->
<a data-remote=false></a> <!-- new behavior, link is not remote -->All the expectations are met, corresponding tests pass. |
9d1b175 to
e9b99b9
Compare
…d").data("remote") === false` if input's data-remote is set to string "false" (`<input id="my_id" data-remote="false" />`)
e9b99b9 to
a940d59
Compare
|
Bump. Rebased from latest @rafaelfranca please, take a look. All tests pass. |
src/rails.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we only need:
// Checks "data-remote" if true to handle the request through a XHR request.|
Sorry for the delay. I made some few comments, otherwise looks good. |
|
@rafaelfranca made suggested changes and CI is 💚 |
…ribute Don't fire ajaxyness if "data-remote"="false"
|
Merged at 99c798d. Thank you |
Hi all,
It seems sort of weird that link/form/btn which has
"data-remote"="false"is treated as if it had"data-remote"="true"(or just"data-remote"). Taking into account that we regularly do use ujs functionality with rails helpers, almost everyone passes a value to thedata-remoteattribute.It will be useful in such cases as the following (simplified example):
Despite the fact the case I stumbled upon is quite rare, having ajax proceeding with
"data-remote"="false"seems weird anyway.