npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-vform

v1.0.4

Published

Vue.js 2 form component that integrates jQuery Validation and Axios.

Downloads

38

Readme

vue-vform

Vue.js 2 form component that integrates jQuery Validation and Axios.

Install

Yarn

yarn add vue-vform --dev

NPM

npm install vue-vform --save-dev

Prerequisites

Usage

Define vform component markup inside your custom component.

For example in your custom-form-component.vue:

<template>

  <vform
    request

    :params="user"
    method="post"
    action="/api/v1/user/add"
    @validate="mySubmitCallback">

    <!-- Your cool stuff -->
    <div class="form-group">
      <label for="txtname">Name</label>
      <input
        name="txtname"
        v-model="user.name"
        required
        data-msg-required="Enter your name"
        type="text" class="form-control">
    </div>

    <div class="form-group">
      <label for="txtemail">E-mail</label>
      <input
        name="txtemail"
        v-model="user.email"
        required
        data-msg-required="Enter your E-mail"
        data-rule-email="true"
        data-msg-email="Enter a valid E-mail address"
        type="text" class="form-control">
    </div>
    <!-- //Your cool stuff -->

    <button type="submit" class="btn btn-primary">Submit</button>

  </vform>

</template>

<script>
  export default {
    data () {
      return {
      	user: {
          name: '',
          email: ''
        }
      }
    },

    methods: {
      /**
       * Callback method when validation is completed.
       */
      mySubmitCallback (promise) {
        promise
          .then(response => response.data)
          .then(data => console.log(data))
          .catch(err => console.log(err.message))
      }
    }
  }
</script>

In your entry app:

const Vue = require('vue')

// jQuery and jQuery Validation
window.$ = window.jQuery = require('jquery')
require('jquery-validation')

// If you want auto form Ajax request (optional)
window.axios = require('axios')

Vue.component('vform', require('vue-vform'))
Vue.component('custom-form-component', require('./components/custom-form-component'))

const app = new Vue({
  el: '#app'
})

Attributes

method (optional)

The request method (POST, PUT, DELETE, PATCH). For dynamic value use v-bind:method="myMethod" or :method="myMethod".

action (optional)

The request URL.

request (optional)

If request (Boolean) attribute is defined vform performs an Ajax Request using Axios and a Promise object is passed to your callback. Make sure that you have Axios before.

params (optional)

The component data binding (usually FormData or plain object {} values) that it will send if request option was setted. (use v-bind:param="mydata" or :param="mydata" property)

accept (optional)

The request Accept header. Default: application/json

Events

@validate

Event when validation is completed. You need to pass the callback defined in your methods: .... A Promise object will be passed if request attribute was defined.

Tip

Laravel v5.4 users: It's necessary to define the Axios common headers in your app.js file. That's is useful when your use Laravel v5.4 and Passport.

axios.defaults.headers.common = {
  'Accept': 'application/json',
  'X-Requested-With': 'XMLHttpRequest',
  'X-CSRF-TOKEN': Laravel.csrfToken
}

License

MIT license

© 2017 José Luis Quintana