This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-05
Channels
- # adventofcode (246)
- # aleph (5)
- # aws (7)
- # beginners (161)
- # boot (3)
- # calva (42)
- # cider (40)
- # clara (10)
- # cljdoc (7)
- # cljs-dev (40)
- # cljsrn (6)
- # clojure (170)
- # clojure-dev (8)
- # clojure-greece (2)
- # clojure-italy (15)
- # clojure-kc (2)
- # clojure-new-zealand (13)
- # clojure-nl (13)
- # clojure-russia (3)
- # clojure-spec (5)
- # clojure-uk (160)
- # clojurescript (72)
- # clojurex (1)
- # cursive (7)
- # data-science (9)
- # datascript (1)
- # datomic (120)
- # devcards (4)
- # emacs (18)
- # figwheel-main (10)
- # fulcro (34)
- # kaocha (3)
- # luminus (1)
- # lumo (6)
- # music (1)
- # nrepl (23)
- # off-topic (2)
- # pedestal (4)
- # re-frame (42)
- # reagent (36)
- # reitit (10)
- # ring-swagger (21)
- # shadow-cljs (124)
- # spacemacs (6)
- # tools-deps (14)
- # unrepl (3)
- # vim (2)
@manu perhaps have a look at re-frame-test
?
Do you want to test how your app is hooked together, or the functions that drive effects?
Hi! I am trying to open a new window at some URL with following code:
[:a {:href url
:target "_blank"
:rel "noopener noreferrer"
:onclick #(do
(js/window.open url "_blank" "noopener")
false)}
url]
However, the URL opens in a new tab instead. If I write :on-click
instead of :onclick
, it opens two tabs.
What am I doing wrong?In the Firefox JavaScript console, the the generated code, when I click on the grey "event" box, looks exactly like this: https://stackoverflow.com/a/15766254/7177944
@urzds I don’t really understand the wizardry of why that stackoverflow answer works, but I wonder if the weirdness is that they are providing text rather than a function
I also found this, but it also behaves in the same way: https://groups.google.com/forum/#!topic/clojurescript/xlsD4iYiYvk
I now have:
:on-click (fn [e]
(.stopPropagation e)
(js/window.open url "_blank")
false)
It appears that I can make it open 1 tab and 1 window by adding the third argument to window.open
: "noopener"
.
What I just noticed is that in Firefox, I see two event handlers registered: click = function emptyFunction() {}
and onClick = ...
with my own code.
this window.open("print.html", "newwindow", "width=300,height=250")
works for me in chrome
And if I change the :a
to a :div
, it works, too. So it really appears to be that the click event is not being ignored...
i was just going to ask that. somewhere in the back of my mind i recall that you have to do something else to make a
tags behave
First comment here confirms it: https://stackoverflow.com/questions/1357118/event-preventdefault-vs-return-false#1357151 (more details: http://blog.niftysnippets.org/2011/11/story-on-return-false.html)
tl;dr: If using Reagent (which via React probably uses the "DOM2 event handlers") only preventDefault
prevents the default action from happening. return false
only worked with DOM0 event handlers, i.e. code in string literals as HTML elements or attached to the .onclick
JS property of the element.
well i’m not sure when it flipped over, but at any rate, you cannot do the return-false-to-prevent-default in any recent react https://reactjs.org/docs/handling-events.html
@lee.justin.m Thanks for the links to the docs!