Giter VIP home page Giter VIP logo

keepjs's Introduction

keepjs

Keep inputs, selects, textareas data, even if web page is refreshed.

Usage

Installation

Include keep.js to your html file

<script type="text/javascript" src="path/to/keep.js"></script>

Method 1

Add keep attribute to the inputs like bellow

<label for="name">
	Enter your name
	<input type="text" name="name" id="name" value="" keep>
</label>

and initialize plugin via Javascript like this

keep()

KeepJS will scan for inputs that have keep in their attributes and will watch data changes.

Method 2

We can also do it only in JS keep([HTMLElement1_ID, HTMLElement2_ID, HTMLElement3_ID, ...HTMLElements_ID]) Strings in array are IDs of the inputs.

keep([
	'birthday',
	'full_name',
	'gender',
	'description',
	'job',
	'favorite_color'
])

Options

In this version (1.0.0) of plugin, only one option is available.

Lazy keeping

Add keep-lazy to the tag or in JS By default, this option is set to true.

keep({
	targets: [ 'birthday', 'full_name', 'gender', 'description', 'job', 'favorite_color' ],
	opts: {
		lazy: Boolean
	}
})

If lazy is falsy, data will be kept on keyup of the inputs.

Multiple keeps

This option will be available soon. By default, this option is set to false. You'll be able to keep more than one value for an tag and choose one when serving data.

Add keep-multiple to the tag or in JS

keep({
	targets: [ 'birthday', 'full_name', 'gender', 'description', 'job', 'favorite_color' ],
	opts: {
		lazy: Boolean,
		multiple: Boolean
	}
})

NOT AVAILABLE IN V-1.0.0

Author

Jean-jacques AKAKPO ([email protected])

An ovaar products

keepjs's People

Contributors

gensjaak avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

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.