name: eldir-add-js-behavior description: Add or update Drupal behaviors in Eldir JavaScript. Use when implementing interactive UI behavior that must be attach/detach-safe for AJAX and progressive enhancement.
Eldir Add JS Behavior
- Add behavior in
js/eldir.jsunderDrupal.behaviors. - Use
once('<key>', '<selector>', context)for idempotent attach. - Use
contextscoping; do not assume full-document attach. - Add
detach()cleanup when using intervals, observers, or external listeners. - Use
Drupal.t()anddrupalSettingswhere appropriate. - Ensure no behavior duplicates existing functionality.
Guardrails
- Keep behavior names explicit and prefixed with
eldir. - Prefer small focused behaviors over one large handler.