Skip to content

diago/ProFiller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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');
}

Releases

No releases published

Packages

No packages published