Code Monkey home page Code Monkey logo

quick-save's Introduction

Quick Save

Utility script for saving forms fields to browser storage using data-attributes. Makes testing form applications quicker. QuickSave uses the element type (i.e input or textarea) and the name attribute to generate a storage key for the data.

Usage

1. Include the Script

Either serve locally or you can use the jsdeliver CDN version:

https://cdn.jsdelivr.net/gh/jamesrwilliams/[email protected]/lib/qs.js

2. Add the data-qa attribute

The script requires a name attribute (this is used for the storage key) for elements you want to be saved:

<input type="text" data-qs name="example" id="name">

N.B - You can change the data- attribute using the attribute option.

3. Initialize:

var qs = new qs();

Options

Change script settings by passing an options object to the constructor, like so:

var qs = new qs({
  
  attribute: 'qs',
  debug: true
  prefix: 'qs_',
  storage: 'local',
  
});
Setting Description Example Value Default Value
attribute Replace the default data attribute to a custom one. Eg data-[attribute] custom-attribute qs
debug Enable verbose feedback on missing attributes true or false true
prefix Use a custom prefix for the storage keys custom_ qs_
storage Change the storage class for the data. session or local local

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.