Skip to content

event handler functions within hiccup-html #103

Open

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.

Activity

  1. ckirkendall commented on Oct 16, 2015

    @ckirkendall
    Owner

    This looks to be an easy fix. Will try to get it in this weekend.

  2. added a commit that references this issue on Oct 16, 2015
  3. ckirkendall commented on Oct 16, 2015

    @ckirkendall
    Owner

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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