Hi, I'm stuck...
Consider this function
<https://github.com/simon-brooke/youyesyet/blob/feature/reflow-app/src/cljs/youyesyet/canvasser_app/ui_utils.cljs#L46>
:
(defn big-link
[text & {:keys [target handler]}]
(js/console.log (str "Big link with target '" target "'; handler '" handler
"'"))
[:div.big-link-container {:key (gensym "big-link")}
[:a.big-link (merge {}
(if target {:href target}{})
(if handler {:on-click handler}{}))
text]])
You'd think that if you passed it a handler, it would generate an on-click
attribute on the anchor. It's called (among other places) here
<https://github.com/simon-brooke/youyesyet/blob/feature/reflow-app/src/cljs/youyesyet/canvasser_app/views/gdpr.cljs#L58>
:
(ui/big-link "I consent"
:handler #(fn
[]
(ui/log-and-dispatch
[:set-consent-and-page
{:elector-id (:id elector)
:page :elector
:elector (merge
elector
:signature
(.toDataURL
sig-pad
"image/svg+xml")
)}])))
And sure enough, it prints in the console log:
Big link with target ''; handler 'function (){
return ((function (elector){
return (function (){
return youyesyet.canvasser_app.ui_utils.log_and_dispatch.call(null,new
cljs.core.PersistentVector(null, 2, 5,
cljs.core.PersistentVector.EMPTY_NODE, [new
cljs.core.Keyword(null,"set-consent-and-page","set-consent-and-page",-160828440),new
cljs.core.PersistentArrayMap(null, 3, [new
cljs.core.Keyword(null,"elector-id","elector-id",1904559247),new
cljs.core.Keyword(null,"id","id",-1388402092).cljs$core$IFn$_invoke$arity$1(elector),new
cljs.core.Keyword(null,"page","page",849072397),new
cljs.core.Keyword(null,"elector","elector",-948994537),new
cljs.core.Keyword(null,"elector","elector",-948994537),cljs.core.merge.call(null,elector,new
cljs.core.Keyword(null,"signature","signature",1463754794),youyesyet.canvasser_app.views.gdpr.sig_pad.toDataURL("image/svg+xml"))],
null)], null));
});
;})(elector))
}'
But when you click the resulting link, nothing at all happens, and what you
get when you inspect the generated element, it is:
<a class="big-link">I consent</a>
So, what am I doing wrong? What do I need to do to get an 'on-click'
handler working? And, if that's not possible, what's the workaround?
I can't extract the signature from the signature pad at page layout time,
because the user hasn't yet signed it. It must be extracted when the link
is selected.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.