Open tacman opened 4 months ago
Do you need more than a simple htmx.logAll()?
Do you need more than a simple htmx.logAll()?
No, I'm a newbie that I simply googled "htmx debug" and saw the extension. But in fact, logAll() does exactly what I was looking for. Thanks!!
Reopening, because the original issue of how to enable extensions persists.
import 'htmx.org/dist/ext/client-side-templates.js';
Same error:
client-side-templates-9a1d1255c92f0d36a12f23f6d1fb02f9.js:7 Uncaught ReferenceError: htmx is not defined at client-side-templates-9a1d1255c92f0d36a12f23f6d1fb02f9.js:7:1
Is there a way to "connect" htmx to the extension in javascript, to avoid this error?
I used to have the problem frequently with jquery plugins, saying jquery wasn't defined.
Here's the actual offending code.
/**
* Bundled by jsDelivr using Rollup v2.79.1 and Terser v5.19.2.
* Original file: /npm/htmx.org@1.9.10/dist/ext/client-side-templates.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
htmx.defineExtension("client-side-templates", {
transformResponse: function(e, t, r) {
var n = htmx.closest(r, "[mustache-template]");
if (n) {
var a = JSON.parse(e)
, s = n.getAttribute("mustache-template");
if (S = htmx.find("#" + s))
I think they are working on improving that for v2. But I can’t say for sure.
I see #1655 also mentions importmaps and es6, I'll change the title because indeed that's the key issues.
es6 and javascript modules are great, and importmaps eliminate the need for build systems.
I hope it get solved!
I see in #2579 that there's a 2.0 beta now! Hopefully these extensions will be able to be included as modules, as I see that @Telroshan has tagged with with 2.0. Let me know when/how to test!
Hey, unfortunately I'm a bit lost when it comes to those modules stuff, though for htmx 2 we moved extensions to a separate repository, where each extension now has its own npm package. Could you test with latest htmx 2 beta version and those new extensions and let me know how it goes?
Coming in after the 2.0.0 release: I was not able to load the SSE-extension as a module with importmaps, because it is not written as such (cf here: https://github.com/bigskysoftware/htmx-extensions/blob/main/src/sse/sse.js). Although htmx seems to ship a module version for the main lib, I think the extensions are not compatible with this.
My workaround was to fall back to script tags, but save the htmx.js and htmx-ext-ssr.js libs to my device and serve them myself with script tags (as htmx documents in their examples) for offline functionality
I've install html and the debug extension, and have loaded them in app.js
This fails with
The documentation show unpkg, but I'm working on an offline project and it needs to run locally, via a downloaded file from jsdelivr.
If I simply import it,
I get this:
Thanks.