-
Notifications
You must be signed in to change notification settings - Fork 508
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
Add support for the data-disable
attribute.
#347
Conversation
element.html(element.data('disable-with')); // set to disabled state | ||
var enabledState = element.html(); | ||
element.data('ujs:enable-with', enabledState); // store enabled state | ||
element.html(element.data('disable-with') || enabledState); // set to disabled state |
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.
Maybe we should try to avoid replacing the html in case there's no disable-with
? We know it should not change at this point right?
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 guess I can bring some of the changes from #348 and avoid these html
calls after all.
This gives the same behavior as the `data-disable-with` attribute, but instead of using a replacement String from the `data-disable-with` attribute the disabled state will use the origin text/value of the element.
Conflicts: test/public/test/data-disable.js
… the HTML after all.
summon @rafaelfranca |
Conflicts: src/rails.js test/public/test/data-disable.js
I experimented with this change this morning. The feature seems to work "as advertised" and I could not find any regression. 👍 I'd definitely like to see this getting merged. BTW: I never noticed disable(-with) works with text inputs and textareas, too :) |
I've been using this ever since without any problems. Will this be merged into master? |
@lucasmazza I just looked through all this, and it looks good to me. Just gotta do some work to rebase it onto master. I'm working on it right now. |
OK, merged in. There were some conflicts that had to be resolved, but seems to be working now. |
thanks @JangoSteve ❤️ I was holding this back to handle all the conflicts in my branch instead of affecting some of the existing PRs. |
Ah makes sense. No worries, we'll get those PRs taken care of. |
This is a spike for what was proposed on #329.
This gives the same behaviour as the
data-disable-with
attribute, but instead of using a replacement String from thedata-disable-with
attribute the disabled state will use the origin text/value of the element. Since there is a lot of shared behaviour betweendata-disable
anddata-disabled-with
I duplicated the test case so we can test the same stuff for both attributes.