peerlibrary / meteor-blaze-components

Reusable components for Blaze
http://components.meteorapp.com/
BSD 3-Clause "New" or "Revised" License
354 stars 26 forks source link

onClick is used before actual click #115

Closed chompomonim closed 8 years ago

chompomonim commented 8 years ago
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 commented 8 years ago

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

mitar commented 8 years ago

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.