Giter Club home page Giter Club logo

profiller's Introduction

ProFiller

Example

Description

ProFiller is used to autocomplete a form using a JSON obect. It requires the Prototype Javascript Framework version 1.6.1 which can be obtained at http://www.prototypejs.org.

Usage

ProFiller is added to Prototypes Form methods:


$('myFormId').fill(json);

Added Methods

fill

$(‘myFom’).fill(data) – fills the form with the supplied JSON data. Also sets up watch so you can easily ask if the form has been changed. Returns the form.


$('myFormId').fill(json); // form is now being watched
if($('myForm').changed()){
  var confirmed = confirm('You have unsaved changes');
}

watch

$(‘myForm’).watch() – Sets up the form to be watched for changes. Basically fills Element#store with a profiller key filled with the serialized form data. Calling watch() will run through the form and replace the current store or create it if necessary. You are not required to call fill(). You can use this method anytime to start watching for changes Returns the form.

changed

$(‘myForm’).changed() – Tests to see if the form has changed (user added to or removed info form the form). You must call either fill() or watch() for changes to be shown. If niether has been called on the form the current form data is stored as the default data to test. Returns boolean.

Options

ProFiller will reset the form before filling by default. To override set resetBeforeFill to false:


$('myFormId').fill(json, false);

Alternate use

ProFiller can also be instantiated and the fill method can be used at will:


var profiller = new ProFiller('myFormId');
profiller.fill(json);
if(profiller.form.changed()){
  var confirmed = confirm('You have unsaved changes');
}

profiller's People

Contributors

diago avatar

Stargazers

 avatar

Watchers

 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.