Conditionize
jQuery plugin for forms conditions to show/hide controls depending on its values.
Demo
Getting Started
CDN
Link directly from unpkg
ES6 import
To use with a bundler like browserify or webpack
;
Set up your HTML
Conditionize Magically show when text control contains 'magic' word. One Two Three. Wow, you will see the new control below... Is checked? Nope Yep GitHub
Call the plugin
;
Options
Name | Type | Default | Description |
---|---|---|---|
selector | string | [data-cond] |
Condition blocks jQuery selector. |
conditionAttr | string | data-cond |
Condition atribute that will be checked. |
checkDebounce | int | 150 |
Debounce timeout for better performance. |
Events
Events used the same way as Options.
Name | Description |
---|---|
onInit | Called after init end. |
onDestroy | Called after destroy. |
onCheck | Called when check function ended work (available 2 arguments [ $item, show ] ). |
customToggle | Custom toggle for conditional blocks. You can define your own function to show/hide blocks. |
Example of customToggle
function:
{ if show $item; else $item; }
Methods
Name | Result | Description |
---|---|---|
destroy | - | Destroy Conditionize and set block as it was before plugin init. |
Call methods example
;
No conflict
If you already have jQuery.fn.conditionize, you can rename the plugin.
jQueryfnnewConditionize = jQueryfnconditionize;
For Developers
Installation
- Run
npm install
in the command line. Or if you need to update some dependencies, runnpm update
Building
npm run build
to run build
Linting
npm run js-lint
to show eslint errorsnpm run js-lint-fix
to automatically fix some of the eslint errors