4 ms·
regardless of what CSS query you use to look the element up, in the jquery example you'd still have your logic (the url, etc) defined elsewhere the htmx versio
by recursivedoubts 2y ago
regardless of what CSS query you use to look the element up, in the jquery example you'd still have your logic (the url, etc) defined elsewhere
the htmx version is symmetric with the href attribute in that it completely specifies what is going to happen directly on the element itself
of course you could do something in jquery like using a data attribute to store the url and HTTP method, etc, but at that point you'd be building https://intercoolerjs.org https://intercoolerjs.org, the predecessor to htmx that was built on top of jquery
- exe34 2y ago> button hx-get="/clicked" that doesn't look like a complete subroutine to me.
- recursivedoubts 2y agoit’s not, but it is a complete specification of behavior, just as <a href=“/clicked”> is
- exe34 2y agothat sounds about as helpful as a chocolate teapot.
- recursivedoubts 2y agoI have never used a chocolate teapot, but anchor tags (and form tags) have been an important piece of the success of the World Wide Web as a hypermedia system. htmx generalizes this notion of hypermedia controls in a syntactically symmetric manner, preserving the locality of behavior inherent in those controls. https://dl.acm.org/doi/pdf/10.1145/3648188.3675127 https://dl.acm.org/doi/pdf/10.1145/3648188.3675127
- exe34 2y agoit's not about the tag, it's about the claim that putting /clicked in the href or equivalent is somehow superior to $("#the-button"). click(function () { do stuff here}).
- recursivedoubts 2y agoright exactly, it is superior in Locality of Behavior (LoB) terms because the behavior of the tag is apparent by only looking at it, whereas in the jquery example the behavior is in code that is located elsewhere. It is also inferior in Separation of Concerns(SoC) terms. These two design principles are in conflict and the reason I invented the term LoB was to help people, like myself, who prefer locality to argue for it effectively in software design discussions.
- exe34 2y agoso a comment would have done the same job? you don't need htmx to add a comment.
- recursivedoubts 2y agoman, that's a really good point
- ndriscoll 2y agoThe htmx behavior is exactly as specified as the jQuery behavior, as what I'm suggesting is the last thing you said: you can literally implement the htmx attributes with jQuery. That factoring has been the recommended way to separate concerns since before jQuery existed (e.g. with xhtml). Selecting specific IDs was always bad practice. Same with CSS. You were meant to use properties. Tellingly, this is how html itself is designed. It's had ways to add your own tags since nearly the beginning, and the built-in ones stand as examples of how to design your custom tags' apis.
- recursivedoubts 2y agoregardless of what CSS query you use to look the element up, in the jquery example you'd still have your logic (the url, etc) defined elsewhere the htmx version is symmetric with the href attribute in that it completely specifies what is going to happen directly on the element itself of course you could do something in jquery like using a data attribute to store the url and HTTP method, etc, but at that point you'd be building https://intercoolerjs.org https://intercoolerjs.org, the predecessor to htmx that was built on top of jquery
- ndriscoll 2y agoThe htmx also has the logic defined elsewhere. It's literally exactly the same html.
- recursivedoubts 2y agowith an anchor tag's href attribute, is the logic defined elsewhere?
- ndriscoll 2y agoIf you're being consistent, yes. The DTD specifies that you should refer elsewhere for the semantics, just as <button hx-get="/clicked"> has semantics that depend on whether you say "this is htmx" or "this is X library based on jQuery". Or alternatively those things all exactly specify the behavior, and you can go look at their specification for the details.