bigskysoftware / htmx

</> htmx - high power tools for HTML
https://htmx.org
Other
37.98k stars 1.29k forks source link

Support Javascript-based requests #103

Open sirinath opened 4 years ago

sirinath commented 4 years ago

Can hx-js be added so content can be returned by JS.

<div hx-js="clicked()"
       hx-trigger="click"
       hx-target="#parent-div"
       hx-swap="outerHTML">
    Click Me!
</div>
1cg commented 4 years ago

maybe we should support the "javascript:" standard from anchor tags:

<a href="javascript:show_more_menu();">More >>></a>

https://stackoverflow.com/questions/7347786/html-anchor-tag-with-javascript-onclick-event

1cg commented 4 years ago

Also worth pondering:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs

sirinath commented 4 years ago

I think the options to have JavaScript or data can replace content would be a great addition. Also using the standard javascript: and data: would be the best options. Also in the case of JS JSX also can be supported.

1cg commented 3 years ago

we have an open branch exploring this option now:

https://github.com/bigskysoftware/htmx/tree/feature_js_expression_support

TastyWaffles commented 3 weeks ago

It's been a few years, what's the status on this? Is it still something that is being looked into? If any assistance is needed l'll try to contribute where I can.

Telroshan commented 3 weeks ago

Is it still something that is being looked into?

Likely not! If it were to be implemented today though, we'd ask for it to start as an extension and not directly added to the core library. If you want to give a shot at implementing this @TastyWaffles , please feel free to do so! You'll want to take a look at the extensions repo as well as the extensions website deployed from it, where we have a section to list community extensions.

TastyWaffles commented 3 weeks ago

Thanks! I'm happy to take a look, no promises though!