Skip to content

event handler functions within hiccup-html #103

@seprich

Description

@seprich

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(&quot;Hi there!&quot;)}">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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions