Fork me on GitHub
#om
<
2016-11-07
>
danielstockton12:11:47

Should pushy not catch clicks on href and prevent the page reloading, or should I be doing that myself somehow?

hlolli13:11:58

@danielstockton Don't use anchorlinks, just use <button> or smth and with :onClick (fn [_] ...) you can add to pushy history and do some state changes in om. That's how I do it, but could be better ways. Then you have the problem if the user reloads the page, where you could transact the state you want to see in componentWillMount.

danielstockton13:11:45

From the pushy docs: "By default pushy will dispatch on all relative URLs and absolute URLs that match the window's origin. This means that all external links will be bypassed."

danielstockton13:11:55

This doesn't seem to be happening though

hlolli13:11:51

If you use html anchor tag <a> (or om.dom/a) then that behaviour will always be evaluated first in the browser. you could do (dom/a #js {:href "#" :onClick #(pushy/push-state ...)) (dont have the pushy functions on top of my head).

danielstockton13:11:27

I guess calling preventDefault doesn't matter, i'll try your workaround

danielstockton13:11:59

I'm trying to use compassus so i'll use something like (compassus/set-route! app :about) in the onClick

hlolli13:11:20

yes sounds like the way to go. But in general, working so much with javascript, I recommend avoiding anchorlinks <a>, I just add in css the hover style then nobody notices a difference.

danielstockton13:11:54

you could argue its less accessible that way, maybe

danielstockton13:11:06

not sure how screenreaders handle onclicks, for example

danielstockton13:11:46

im being quite pernickety, but would rather get these things right from the beginning

hlolli13:11:45

yes, not sure with the screenreaders, I've never done mobile development so far but the websites I've built work fine in iphone and samsung. When I see some react addons giving the option :onTap :onTouch, I have no idea what to use it for.

hlolli13:11:03

or did you mean that by screenreaders?

danielstockton13:11:55

I meant programs that read things aloud for blind people but it can probably be fixed by setting other attributes properly, I doubt they use the href. Also, really not a concern for what I'm doing right now but I'm just trying to establish the best practice.

hlolli13:11:13

ahh ok, yes. With the emergence of SPA many technologies have had to change. Somehow the google-spiders can recursively open a react website and document the hrefs.

danielstockton14:11:24

@hlolli It was actually another problem entirely. I was missing an om/util function, which led me to update om.next and cljs. Now it works perfectly fine with href...

alex-glv20:11:48

Is it a bad practice to pass full query to Datomic back-end including back-references (eg :some-entity/_backref) ? I tried to only pass the key, but it seems it’s only possible to set :query-root on join queries rather than simple keys, so I though I’d send the whole thing.

mitchelkuijpers21:11:38

@danielstockton @hlolli using anything other than anchors for links in single page app breaks browser behavior of ctrl+click on a link please don’t do that

mitchelkuijpers21:11:22

Sorry had to say this, I absolutely hate single page apps that break this.. 😅