-
Notifications
You must be signed in to change notification settings - Fork 35
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
bind disabled attribute to more logic - eg. validation of form #58
Comments
couldn't you just do something like: {{async-button disabled=isValid}} /cc @danmcclain |
@bcardarella Confirm, the |
Actually, I think binding a |
The problem with @danmcclain is correct, binding a |
@Iftahh I suspect a new CP would have to be written that is similar to: // in your app you'll have to override the component:
// app/components/async-button.js
import Ember from 'ember';
import AsyncButtonComponent from 'ember-cli-async-button/components/async-button';
const {
computed
} = Ember;
export default AsyncButtonComponent.extend({
disabled: computed('textState', 'isValid', function() {
let textState = get(this, 'textState');
let isValid = get(this, 'isValid');
if (!isValid) {
return false;
} else if (textState === 'pending') {
return false;
} else {
return true;
}
})
}); Then when you call the component you can do: |
Thanks! |
This is what the disableWhen option is for: {{async-button disableWhen=isInvalid}} We could name this option just |
I have a form with validation and an async "submit" button,
I would like to make the button disabled when the validation fails OR while the async action is taking place.
Is there an elegant way to make it happen?
I recommend adding this use case to the documentation/demo because the form+validation+async+submit is a very common use case.
The text was updated successfully, but these errors were encountered: