Nupital Pomp Mesmerises

    fruitmachine-form

    0.0.2 • Public • Published

    fruitmachine-form

    A form FruitMachine helper. Hijacks the form's submit event and turns it into an ajax request. Dependent on superagent.

    If you want your <form>'s ajax request to use a different URL than its action attribute, set a data-action.

    For example:

    <form method="post" action="/login" data-action="/login.json">
      [...]
    </form>
    

    Currently compatible with standard <input> and <select> fields.

    To catch the response from the ajax request simply implement onSubmitResponse on your module. onSubmitResponse will be called with the same parameters as superagent's end method.

    Todo

    • Tests.
    • Tidy up the way it serializes forms. Possibly try to depend on another project.

    Keywords

    none

    Install

    npm i fruitmachine-form

    DownloadsWeekly Downloads

    4

    Version

    0.0.2

    License

    none

    Last publish

    Collaborators

    • mattandrews