-
Notifications
You must be signed in to change notification settings - Fork 235
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
Indicator and disable for form submit #220
Comments
I do it like this: $(document).on('beforeSend.ic', function (event, el, data) {
if (el.is('form')) {
// disable button
el.find('input[type="submit"], button[type="submit"]').prop('disabled', disable);
// ensure we don't submit if already submitted
if (el.hasClass('form-submitted')) {
event.preventDefault();
} else {
// show spinner
const spinner = el.find('.fa-spinner');
if (spinner) {
spinner.show();
}
el.addClass('form-submitted');
}
}
}); |
This should be part of the default behavior for forms. I will look at adding it. |
on the code disabled css class is added. https://github.com/intercoolerjs/intercooler-js/blob/master/src/intercooler.js#L343 Must be a disabled property! |
PR #284 |
some news about this ? |
Hi @zodman I have looked into this. It looks like the disabled attribute only apply to inputs: https://www.w3schools.com/tags/att_disabled.asp Not to forms. Do you have a link specifying otherwise? |
let me edit the PR to apply to all inputs.. wait for it. |
patch apply! |
Buttons have great build-in functionality - when triggered, display loading indicator and set 'disabled' class
But if I have a form with submit button:
<form ic-post-to="/items/add" ic-target="#items">
..fields...
<button type="submit">Add <i class="fa fa-spinner fa-spin"></i></button>
</form>
And click 'Add' button - no indicator and no diasble. Becouse not submit was triggered , but the form itself.
Forms with submits is very common use-case, is there way to automatically display indicator and disable submit-buttons then submitting form?
Currently, indicator can be displayed via ic-indicator attribute at form, a little clumsy, but ok. But how to declaratively disable submit button?
The text was updated successfully, but these errors were encountered: