Skip to content

This little plugin helps to declare complex form logic, like 'show this <input> when user select this option'. Yes! In declarative style.

Notifications You must be signed in to change notification settings

plagi/jquery-grewform

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quickstart

`$('form selector').grewform({
	//Selectors are jCSS/jQuery compatible. You can select inputs by values setted runtime: 'input[value=foo]'
	'rule_selector' or 'rule_selector_1 AND rule_selector_2]:
	{		
		//all actions are optional and rolls back automatically
		show:'elements_selector',	//showing elements (slideDown; slideUp on rollback)
		hide:'elements_selector',	//hiding elements (slideUp; slideDown on rollback)
		disable:'elements selecotr'	//adding disabled="disabled" to attributes (remove on rollback)
		enable:'elements selecotr'	//removing disabled from attributes (adding on rollback)
		check:'elements selecotr'	//adding disabled="checked" to attributes (remove on rollback)
		uncheck:'elements selecotr'	//removing checked from attributes (adding on rollback)
		set_value:<elements_selector>,	//setting value (<input> and <select> are supported)
		add_options: 			//for adding options to selects
		{
			'<select> selector':{
	                      <value_1>:<display_value_1>,
	                      <value_2>:<display_value_2>,
			      ...
	              	}
			or
			'<select> selector': function	//should return obj formatted like described above
		},
		custom:		//for custom actions
		{
			match:function,		//will be called when rule selector matches at least one element
			unmatch:function,	//will be called on rollback
		}

})`

Check out demos

About

This little plugin helps to declare complex form logic, like 'show this <input> when user select this option'. Yes! In declarative style.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published