Use this Vue directive to add a loader on a <form>
s submit event.
You can install the package via yarn:
yarn add vue-form-loader
or npm:
npm install vue-form-loader --save
Import the directive and use it:
// Eg. in app.js
import FormLoader from 'vue-form-loader';
Vue.use(FormLoader);
There are several ways to use the directive on a <form>
.
// Eg. in app.js
const app = new Vue({
el: '#app',
mounted() {
FormLoader.autoBindToForms();
}
});
<form v-loading>
<button type="submit">Submit form</button>
</form>
<template>
<form v-loading="loading">
<button type="submit">Submit form</button>
</form>
</template>
<script>
export default {
data() {
return {
loading: false
}
}
}
</script>
You need to create the css for button loader yourself. When a form submits,
the class is-loading
will be added to the submit button (must be of `type="submit").
To change which class the directive adds/removes:, set FormLoader.loadingClass
in your app.js
On form submission, the submit button(s) will be disabled
to prevent erroneous double submissions.
Buttons with the name
attribute will however not be disabled since that would prevent them from
being included in the request. To make sure they are disabled, use css and target the loading class instead.
yarn start
will start the dev server to load the docs/index.html
example file.
- Build changes:
yarn build
- Bump version:
npm version major/minor/patch
- Publish:
npm publish
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please contact Victor Eliasson instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.