Socket
Socket
Sign inDemoInstall

vue-form-loader

Package Overview
Dependencies
10
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vue-form-loader

Directive which handles loading for when the form submits


Version published
Weekly downloads
104
decreased by-39.18%
Maintainers
1
Install size
14.9 kB
Created
Weekly downloads
 

Readme

Source

Vue Form Loader Directive

Latest Version on NPM Software License

Use this Vue directive to add a loader on a <form>s submit event.

Installation

You can install the package via yarn:

yarn add vue-form-loader

or npm:

npm install vue-form-loader --save

Usage

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>.

Bind the directive automatically to all <form> elements:
// Eg. in app.js
const app = new Vue({
    el: '#app',
    mounted() {
        FormLoader.autoBindToForms();
    }
});
Add the directive to a regular <form>:
<form v-loading>
    <button type="submit">Submit form</button>
</form>
Add the directive to a Vue-component <form> to sync the loading state:
<template>
    <form v-loading="loading">
        <button type="submit">Submit form</button>
    </form>
</template>
<script>
    export default {
        data() {
            return {
                loading: false
            }
        }
    }
</script>

The loader class

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

Disabling

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.

Developing

yarn start will start the dev server to load the docs/index.html example file.

Publish a new release:

  • Build changes: yarn build
  • Bump version: npm version major/minor/patch
  • Publish: npm publish

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please contact Victor Eliasson instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

Credits

Keywords

FAQs

Last updated on 01 Jul 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc