Please support `up.reload(":none")` · Issue #563 · unpoly/unpoly · GitHub
Skip to content

Please support up.reload(":none") #563

Open

Description

@mordae

Using up.reload(":none") should make the request as usual but only update hungry elements for consistency with up-target=":none". It currently crashes, unable to find an actual ":none" inside the fragment.

As for when this is needed, upon clicking the cart icon, an interactive cart drawer opens. Once user finishes editing the quantities and possibly remove some products from the cart, they dismiss the drawer. Upon dismiss, on-dismiss reloads the parent layer to reflect changes the user made. Since the page also contains other interactive widgets that need to retain their state, it is undesirable to perform a full reload. Refreshing just the hungry elements suffices.

I have worked around the issue by reloading the button itself instead, but that makes the intent pretty non-obvious.

Activity

  1. changed the title [-]Support `up.reload(":none")`[/-] [+]Please support `up.reload(":none")`[/+] on Nov 29, 2023
  2. triskweline commented on Nov 29, 2023

    @triskweline
    Contributor

    When reloading Unpoly needs an element to discover which URL to reload from, and which ETags / Last-Modified headers to send.

  3. mordae commented on Dec 7, 2023

    @mordae
    ContributorAuthor

    Ah, I see. Would it be possible to support the behavior described above as an option then? For example by making it possible to pass update targets that further restrict what children of the target element are actually replaced?

  4. yaroslav-gwit commented on Jan 17, 2024

    @yaroslav-gwit

    I worked around a similar issue another way. I've created a JS function that was listening for a particular event (path change in my case, but it can be anything really), and once the event was triggered a block of code below had to update few elements (at once) on the page:

    // vmName variable was set above this block, to make an element that has to be updated more dynamic
    if (document.location.pathname.includes('/hosts/')) {
        up.render(`#vmActionButtons, .unpoly-snapshot-list`, { url: document.location.pathname });
    } else {
        up.render(`#vmActionButtons, #sidebarVm${vmName}, .unpoly-snapshot-list`, { url: document.location.pathname });
    }

    I hope this helps, or at least gives you some new ideas :)

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