6 ms·
hx-on is the general js API from htmx, it's essentially a wrapper/shortcut for creating a js event handler. The htmx docs provide some examples https://htmx.or
by 411111111111111 3y ago
hx-on is the general js API from htmx, it's essentially a wrapper/shortcut for creating a js event handler. The htmx docs provide some examples
https://htmx.org/attributes/hx-on/ https://htmx.org/attributes/hx-on/
- intrasight 3y agoI had found that. It has the "what" but not the "where or why"
- renerick 3y agoBecause HTML's on* attributes are not generic, they are hardcoded in the spec, you can't use them to handle arbitrary events. hx-on is an attempt to fill this gap for simple cases, when managing event listeners manually or resorting to _hyperscript or alpine is too much > it addresses a specific shortcoming of HTML: the on* attributes do not support arbitrary events > it is much less featureful & useful than, for example, @Alpine_JS, but if you have very basic needs for event handling it can help avoid another dependency https://nitter.net/htmx_org/status/1679966199667478531#m https://nitter.net/htmx_org/status/1679966199667478531#m
- intrasight 3y ago> it addresses a specific shortcoming of HTML: the on* attributes do not support arbitrary events Yes, I saw that. But what does it have to do with XPath?
- renerick 3y agoXPath is implementation detail, used for searching of attributes with a give prefix, and this article is just a public note of how it was done in htmx
- intrasight 3y agoGot it. Thanks.
- dgb23 3y agoYou mean htmx in general? The author of htmx wrote a rationale (when and when not to use it). https://htmx.org/essays/when-to-use-hypermedia/ https://htmx.org/essays/when-to-use-hypermedia/
- intrasight 3y agoGood article, but I saw no mention of hx-on