Skip to content

setAttribute('hx-ignore') does not disable htmx in 4.0 #4061

Description

@salomvary

Was working with setAttribute('hx-disable'), 4.0 upgrade documents claim that this attribute was only "renamed" but there seems to be a behavior change: https://four.htmx.org/docs/whats-new-in-htmx-4

Showcase:

<!doctype html>
<title>Test</title>
<script src="https://cdn.jsdelivr.net/npm/htmx.org@4.0.0/dist/htmax.js"
        integrity="sha256-fefTvViCN3FkUZr3FwhEtzdQVMDzT2F/rOyk86Um93E="
        crossorigin="anonymous"></script>

<script>
  htmx.config.logAll = true;
</script>

<button onclick="this.nextElementSibling.setAttribute('hx-ignore', '')">Ignore next button</button>
<button hx-get="" hx-swap="none">Click me</button>

Expected: Clicking "Click me" should not make a request after clicking "Ignore next button".
Actual: It makes a request.

Workaround:

Use htmx.process(element, true) after setting hx-ignore.

<button onclick="this.nextElementSibling.setAttribute('hx-ignore', ''); htmx.process(this.nextElementSibling, true)">Ignore next button</button>
<button hx-get="" hx-swap="none">Click me</button>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions