PHPackages                             dlds/yii2-jqhooks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dlds/yii2-jqhooks

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

dlds/yii2-jqhooks
=================

Yii2 jQuery action hooks

2.0(9y ago)02.3kBSDJavaScript

Since Nov 10Pushed 8y ago1 watchersCompare

[ Source](https://github.com/dlds/yii2-jqhooks)[ Packagist](https://packagist.org/packages/dlds/yii2-jqhooks)[ RSS](/packages/dlds-yii2-jqhooks/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (6)Versions (8)Used By (0)

jQuery action hooks
===================

[](#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
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
$ composer require dlds/yii2-jqhooks
```

or add

```
"dlds/yii2-jqhooks": "~1.0"

```

to the `require` section of your `composer.json` file.

Usage
-----

[](#usage)

You want to show 'overlay' html element when user clicks on 'trigger' html element. With Action hooks you have to do:

1. Register hook

```

```

2. Register trigger

```

```

> Each registered hook must have **data-hook="{hookName}"** attribute. Each trigger element must have **data-had="{hookActionDefinition}"** attribute

Format
------

[](#format)

Hook action definition (data-had) format:

```
{
  'jqEevent' => [
    ['hookActionName' 'hookName', 'hookActionCondition'],
  ]
}
```

Attributes
----------

[](#attributes)

1. `jqEvent` is classic jQuery event like 'change', 'click', ...
2. `hookActionName` is jqhooks aciton method name (doClose, doOpen, doToggle, ...).
3. `hookName` is custom string which reflects value of 'data-hook' attr assigned to target element
4. `hookActionCondition` 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
-------

[](#actions)

1. `doOpen` add class 'open' to hooked element
2. `doClose` remove class 'open' to hooked element
3. `doShow` shows hooked element (calls $.show())
4. `doHide` hides hooked element (calls $.hide())
5. `doToggle` toggles hooked element (calls $.toggle())
6. `doCheck` adds property 'checked=true' to hooked element
7. `doUncheck` rmeoves property 'checked=true' to hooked element

Ternary usage
-------------

[](#ternary-usage)

You can specify ternary condition like following:

```
{
  'click' => [
      ['show:hide' 'overlay', 'return this.val() === 1'],
  ]
}
```

This definitios runs 'show' action if clicked element value === 1 otherwise it runs 'hide' action.

Helper
------

[](#helper)

You can simple use `JqHooks::attach()` which registeres proper js and runs initialization on document ready.

```
JqHooks::attach([
  'click' => [
      ['show:hide' 'overlay', 'return this.val() === 1'],
  ]
])
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 62.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~14 days

Total

7

Last Release

3430d ago

Major Versions

1.5 → 2.02017-02-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/23f0d05bb48111bd348c97af007c453b374ba03c36ec4fd114dfd73896bf5958?d=identicon)[dlds](/maintainers/dlds)

---

Top Contributors

[![jirisvoboda](https://avatars.githubusercontent.com/u/10264326?v=4)](https://github.com/jirisvoboda "jirisvoboda (15 commits)")[![svobik7](https://avatars.githubusercontent.com/u/761766?v=4)](https://github.com/svobik7 "svobik7 (9 commits)")

---

Tags

helpersjqueryyii2

### Embed Badge

![Health badge](/badges/dlds-yii2-jqhooks/health.svg)

```
[![Health](https://phpackages.com/badges/dlds-yii2-jqhooks/health.svg)](https://phpackages.com/packages/dlds-yii2-jqhooks)
```

###  Alternatives

[asinfotrack/yii2-toolbox

Yii2-Toolbox is a collection of useful helpers, widgets etc. extending the basic functionality of Yii2

1130.8k5](/packages/asinfotrack-yii2-toolbox)[yiier/yii2-helpers

Helpers for Yii2

117.0k2](/packages/yiier-yii2-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
