Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onClick is used before actual click #115

Closed
chompomonim opened this issue Feb 2, 2016 · 2 comments
Closed

onClick is used before actual click #115

chompomonim opened this issue Feb 2, 2016 · 2 comments

Comments

@chompomonim
Copy link

template(name="hello")
  a(href="/hello" onClick=onClick) Click me
class Hello extends BlazeComponent
  @register 'hello'

  onClick: (event) ->
    console.log 'Hello!'
    event.preventDefault()

Refresh the page (no clicks) and in console I can see:

> Hello!
> Exception in template helper: TypeError: Cannot read property 'preventDefault' of undefined
@rclai
Copy link

rclai commented Feb 2, 2016

Don't you need to use the event map? I don't think you can bind events like that.

@mitar
Copy link
Member

mitar commented Feb 2, 2016

This works only with HTML templates. Jade has not been ported to them. Something like the following has to be done:

https://github.com/peerlibrary/meteor-blaze-components/blob/master/patch-compiling.js

Duplicate of #113.

Don't you need to use the event map? I don't think you can bind events like that.

Yes you can with recent version of Blaze Components.

@mitar mitar closed this as completed Feb 2, 2016
@mitar mitar added the duplicate label Feb 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants