htmx icon indicating copy to clipboard operation
htmx copied to clipboard

hx-on unbound namespace in Jetbrains IDEs

Open bavjackson opened this issue 1 year ago • 3 comments

I'm having issues with the hx-on attribute when working on html in Pycharm.

This only seems to be an issue with hx-on, every other attribute is fine.

image

Is there any easy fix to silence the IDE?

bavjackson avatar Nov 25 '24 17:11 bavjackson

Looks like this needs to be added to the web-types file?

bavjackson avatar Nov 25 '24 17:11 bavjackson

Looks like this needs to be added to the web-types file?

Probably, if you feel like investigating, a fix PR would be welcome! 😄

Other than that, looking at the highlighted error, there could be an issue with the attribute's syntax (as only hx-on seems to be underlined here and not the full attribute hx-on::after-settle), in which case you might want to try the trick mentioned in the docs:

Finally, in order to make this feature compatible with some templating languages (e.g. JSX) that do not like having a colon (:) in HTML attributes, you may use dashes in the place of colons for both the long form and the shorthand form:

<!-- These two are equivalent -->
<button hx-get="/info" hx-on-htmx-before-request="alert('Making a request!')">
    Get Info!
</button>

<button hx-get="/info" hx-on--before-request="alert('Making a request!')">
    Get Info!
</button>

Telroshan avatar Nov 26 '24 07:11 Telroshan

Probably, if you feel like investigating, a fix PR would be welcome! 😄

I might give this a try at the weekend.

Finally, in order to make this feature compatible with some templating languages (e.g. JSX) that do not like having a colon (:) in HTML attributes, you may use dashes in the place of colons for both the long form and the shorthand form:

This is working for now, thanks.

bavjackson avatar Nov 26 '24 11:11 bavjackson