Add coexistence checks to all enqueue methods to prevent loading both React and Grid.js assets simultaneously. Changes: - ReactAdmin.php: Only enqueue React assets when ?react=1 - Init.php: Skip Grid.js when React active on admin pages - Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0 - Customer.php, Product.php, License.php: Add coexistence checks Now the toggle between Classic and React versions works correctly. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2.5 KiB
2.5 KiB
delegate
Lightweight event delegation.
Install
You can get it on npm.
npm install delegate --save
If you're not into package management, just download a ZIP file.
Setup
Node (Browserify)
var delegate = require('delegate');
Browser (Standalone)
<script src="dist/delegate.js"></script>
Usage
Add event delegation
With the default base (document)
delegate('.btn', 'click', function(e) {
console.log(e.delegateTarget);
}, false);
With an element as base
delegate(document.body, '.btn', 'click', function(e) {
console.log(e.delegateTarget);
}, false);
With a selector (of existing elements) as base
delegate('.container', '.btn', 'click', function(e) {
console.log(e.delegateTarget);
}, false);
With an array/array-like of elements as base
delegate(document.querySelectorAll('.container'), '.btn', 'click', function(e) {
console.log(e.delegateTarget);
}, false);
Remove event delegation
With a single base element (default or specified)
var delegation = delegate(document.body, '.btn', 'click', function(e) {
console.log(e.delegateTarget);
}, false);
delegation.destroy();
With multiple elements (via selector or array)
Note: selectors are always treated as multiple elements, even if one or none are matched. delegate() will return an array.
var delegations = delegate('.container', '.btn', 'click', function(e) {
console.log(e.delegateTarget);
}, false);
delegations.forEach(function (delegation) {
delegation.destroy();
});
Browser Support
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| Latest ✔ | Latest ✔ | Latest ✔ | 9+ ✔ | Latest ✔ | Latest ✔ |
License
MIT License © Zeno Rocha





