You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm considering making use of app specific custom htmx extensions like the example below and was wondering if there are any drawbacks to this approach. I like that it easily lets me encapsulate everything related to the element the extension is attached to in it's own Ts/Js file.
Then my hour-slider extension could be something like this:
importhtmxfrom'htmx.org';constext='hour-slider';(function(){htmx.defineExtension(ext,{onEvent: function(name,event){if(name!=='htmx:afterProcessNode'){return;}constel=event.targetasHTMLElement;el.addEventListener('input',function(event){consttarget=event.targetasHTMLInputElement;// client side actions...});el.addEventListener('mouseup',function(event){consttarget=event.targetasHTMLInputElement;htmx.ajax('POST','/somewhere',{swap: 'none',values: target.value}).then(()=>{// do something...});});}});})();
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm considering making use of app specific custom htmx extensions like the example below and was wondering if there are any drawbacks to this approach. I like that it easily lets me encapsulate everything related to the element the extension is attached to in it's own Ts/Js file.
Then my
hour-slider
extension could be something like this:Beta Was this translation helpful? Give feedback.
All reactions