Fork me on GitHub
#clojurescript
<
2022-01-26
>
bastilla14:01:17

Hi! Concerning regular HTML page anchors you'd normally address like "http://some-random-ww-page.com#news-section", etc. (note .com#news-section) - How would I use/reactivate this mechanism beside JS/Clojurescript routing? (I'm using Luminus w/ reitit routing.) Any hints, or links to that approach. Couldn't find any. THANKS!

magnars14:01:47

Are you looking for (set! js/location.hash "my-anchor") ?

p-himik14:01:16

And if not, we need a clarification on the "use/reactivate" part.

bastilla15:01:03

Hi you both & THX for chiming in. Such URLs in the browser http://mypage.com#sub-section fire up JS re-routing to http://mypage.com/#sub-section. (= blank page bc no routing for this is defined.) "sub-section" is just an HTML id within the SPA page already loaded, which I want users to jump to. You know, this standard HTML behaviour (before the age of JS routing via /#. Users need both here (long page). Hope I didn't talk nonsense.

bastilla15:01:39

PS: Concerning (set! js/location.hash "my-anchor" I think this would fire be same behaviour as editing the browser's URL location. (adding #abc)

magnars15:01:54

It sounds to me like either Luminus or Reitit is defaulting to use location.hash for routing, and you don't want that. I think most web sites moved away from having their routing behind # quite a while ago. If you can set up your backend to respond with the SPA on several URLs, then you could probably switch to routing over to using the actual URL, and regain the original hash functionality.

2
bastilla15:01:34

Very interesting! I need to digest this. Many thanks @U07FCNURX! And @U2FRKM4TW