1.1.0 • Published 5 years ago
formless-button v1.1.0
Formless Button
Handle button click as form submit.
Installation
npm i formless-button
Requirements
In order to work properly, you have to add meta tag with CSRF token into <head>
<meta name="csrf-token" content="AAABBBCCCDDDEEE">For Laravel:
<meta name="csrf-token" content="{{ csrf_token() }}">Usage
In your JS file just import FormlessButton.js, for example
import FormlessButton from "formless-button/FormlessButton";FormlessButton will query <button> with data-method and data-url attributes.
<button data-method="DELETE" data-url="https://example.com/user/44">Delete user</button>Under the hood, FormlessButton will listen for click event, after that FormlessButton will create & submit basic <form> with _token and _method inputs.