fresh icon indicating copy to clipboard operation
fresh copied to clipboard

Feat: trigger partial route change from JS

Open sonickseven opened this issue 1 year ago • 7 comments

I know about of partial and I applied the documentation fine, but in some cases I need change of page with logic(JS or TS) and I tried with window.location.href , document.location.href and location.href but in all cases the change of pages refresh all website.

How I can change with JS of page like for example navigate(/link/foo=bar); from reactjs or with Router.push() from nextjs

Also I tried with this code:

location.href = new URL(`/link/foo=bar`, location.origin).href;

But it doesn't work 😭

sonickseven avatar Jan 10 '24 03:01 sonickseven

Client side routing is done via Partials in Fresh, see https://fresh.deno.dev/docs/concepts/partials

marvinhagemeister avatar Jan 10 '24 09:01 marvinhagemeister

But only works with tag A and I could't see how use that with JS, if you know that please show me one example 🙏

sonickseven avatar Jan 10 '24 21:01 sonickseven

Yeah it's currently limited to anchor tags and forms. There currently is no API to access it from JS.

Re-opening because a question turned into a feature request.

marvinhagemeister avatar Jan 11 '24 08:01 marvinhagemeister

Yeah it's currently limited to anchor tags and forms. There currently is no API to access it from JS.

Re-opening because a question turned into a feature request.

When I was researching I saw this same problem in stackoverflow, reddit.

sonickseven avatar Jan 11 '24 11:01 sonickseven

Yeah it's currently limited to anchor tags and forms. There currently is no API to access it from JS. Re-opening because a question turned into a feature request.

When I was researching I saw this same problem in stackoverflow, reddit.

I'm afraid I don't track those places. I mostly monitor this repository here or our discord.

marvinhagemeister avatar Jan 11 '24 11:01 marvinhagemeister

+1

spy4x avatar Sep 10 '24 06:09 spy4x