Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hyperlink w/target="_blank" and hx-boost="false" is being reported as a boosted link #484

Closed
bschollnick opened this issue Sep 10, 2024 · 1 comment

Comments

@bschollnick
Copy link

bschollnick commented Sep 10, 2024

Python Version

3.12.5

Django Version

5.1.1

Package Version

1.19.0

Description

I'm attempting to open the next page in a new window/tab, using target="_blank" in the hyperlink, e.g.:

{{ icon('fas fa-external-link-alt fa-3x') }}

My view logic is based entirely around the request.htmx.boost boolean:

   if request.htmx.boosted:
        print("partial")
        template_name = "frontend/gallery_htmx_partial.jinja"
    else:
        print("full")
        template_name = "frontend/gallery_htmx_complete.jinja"
    if not filetypes.models.FILETYPE_DATA:
        print("Loading filetypes")
        filetypes.models.FILETYPE_DATA = filetypes.models.load_filetypes()
    i_uuid = str(i_uuid).strip().replace("/", "")
    context = build_context_info(request, i_uuid) | {"user": request.user} # | {"sort": sort_order(request), "uuid": i_uuid, }
    response = render(
        request, template_name, context, using="Jinja2"
    )
    return response

This link is being shown as boosted, even though hx-boost is set false. I'm unclear if this is a htmx issue, or a django-htmx issue. How can I troubleshoot this further, to help identify what is causing this issue?

@adamchainz
Copy link
Owner

request.htmx.boost only reads the header from htmx. It sounds like an htmx issue that it's sending the header despite your request not to do that.

Remember that htmx attributes are inherited, so if you put hx-boost="true" somewhere high in the DOM tree, it applies to all links below.

@adamchainz adamchainz closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants