enfocus
enfocus copied to clipboard
event handler functions within hiccup-html
Hi, I am not sure whether this is supposed to be supported or not:
(defn set-application []
(let [content (ef/html [:div [:h1 "Testing"]
[:button {:onclick #(.log js/console "TESTING")} "Test it!"]])]
(ef/at ["#application"] (ef/content content))))
Anyway the onclick function is broken and does not work in chromium nor in firefox. In both I get "Uncaught SyntaxError: Unexpected token (" . ~~pointing just to the first line of my index.html without decent explanation (and I have the .js.map file in place).~~ The generated html looks like this:
<div>
<h1>Testing</h1>
<button onclick="function (){return console.log("Hi there!")}">Test it!</button>
</div>
This inlined js is clearly broken (at the very least something like "(function () {...})()" -wrapping is missing). Anyway supporting embedded event handlers would be a powerful feature.
This looks to be an easy fix. Will try to get it in this weekend.
If you could can you pull down the latest and do an lein install and test it with your app before I make a release. I pushed up the fix.