iptools-jquery-populator
jQuery plugin that populates form control value(s) to other control(s).
Installation
bower install iptools-jquery-populator
Features
- Populate values automatically from one form control to the other on its
change
orblur
events based ondata-population-target
attribute - Populate values manually from one form control to the other with
populateManual()
method call based ondata-population-target-manual
attribute - Listen to population to retrieve event
type
,source
andtarget
controls of the population - Populate single value to multiple targets
Options
All options are delivered over data attributes on form controls which values should be populated to other control(s).
Option | Description |
---|---|
data-population-target |
Single or comma-separated list of selectors for form controls receiving data on change or blur events |
data-population-target-manual |
Single or comma-separated list of selectors for form controls receiving data on populateManual() method call |
Events
Events are dispatched on element that populator was initialised on, e.g. <form>
.
Event | Description |
---|---|
success |
Dispatched whenever value was populated successfully. |
error |
Dispatched whenever values was popuplated erroneously. |
Event structure:
{
type: '<event type>', // populationMismatch or populationSuccess
target: '<jQuery Object>', // target element receiving populated value
source: '<jQuery Object>', // source element defining populated
}
Requirements
- jQuery 1.3.2 or greater
Example
<form action="/billing" method="post">
<input type="text" data-population-target="#js_shipping_name" name="billing_name" value="Interactive Pioneers GmbH">
</form>
<form action="/shipping" method="post">
<input type="text" name="shipping_name" id="js_shipping_name">
</form>
<script>
jQuery(document).ready(function($) {
$('form:first').iptPopulator();
});
</script>
Contributions
Bug reports, suggestions
- File all your issues, feature requests here
- If filing a bug report, follow the convention of Steps to reproduce / What happens? / What should happen?
- If you're a developer, write a failing test instead of a bug report and send a Pull Request
Code
- Fork it ( https://github.com/[my-github-username]/iptools-jquery-populator/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Develop your feature by concepts of TDD, see Tips
- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Tips
Following tasks are there to help with development:
-
grunt watch:bdd
listens to tests and source, reruns tests -
grunt qa
run QA task that includes tests and JSHint -
grunt build
minify source to dist/
Licence
Copyright © 2015 Interactive Pioneers GmbH. Licenced under GPLv3.