Download the PHP package dlds/yii2-jqhooks without Composer
On this page you can find all versions of the php package dlds/yii2-jqhooks. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-jqhooks
jQuery action hooks
Action hooks is simple jQuery helper library. Used when jQuery operation like show, hide, toggle, ... are required to attach with conditional ability.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require
section of your composer.json
file.
Usage
You want to show 'overlay' html element when user clicks on 'trigger' html element. With Action hooks you have to do:
-
Register hook
- Register trigger
Each registered hook must have data-hook="{hookName}" attribute. Each trigger element must have data-had="{hookActionDefinition}" attribute
Format
Hook action definition (data-had) format:
Attributes
jqEvent
is classic jQuery event like 'change', 'click', ...hookActionName
is jqhooks aciton method name (doClose, doOpen, doToggle, ...).hookName
is custom string which reflects value of 'data-hook' attr assigned to target elementhookActionCondition
callback or simple fn definition which will be processed as js function. This condition allows you to define when the action will be processed.
Actions
doOpen
add class 'open' to hooked elementdoClose
remove class 'open' to hooked elementdoShow
shows hooked element (calls $.show())doHide
hides hooked element (calls $.hide())doToggle
toggles hooked element (calls $.toggle())doCheck
adds property 'checked=true' to hooked elementdoUncheck
rmeoves property 'checked=true' to hooked element
Ternary usage
You can specify ternary condition like following:
This definitios runs 'show' action if clicked element value === 1 otherwise it runs 'hide' action.
Helper
You can simple use JqHooks::attach()
which registeres proper js and runs initialization on document ready.