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

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

Open
mordae opened this issue Nov 29, 2023 · 3 comments
Open

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

mordae opened this issue Nov 29, 2023 · 3 comments

Comments

@mordae
Copy link
Contributor

mordae commented Nov 29, 2023

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.

@mordae mordae changed the title Support up.reload(":none") Please support up.reload(":none") Nov 29, 2023
@triskweline
Copy link
Contributor

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

@mordae
Copy link
Contributor Author

mordae commented Dec 7, 2023

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?

@yaroslav-gwit
Copy link

yaroslav-gwit commented Jan 17, 2024

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants