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

Template level event binding doesn't work with meteor-jade? #113

Open neoromantic opened 8 years ago

neoromantic commented 8 years ago

I'm using mquandalle:jade package to have '.jade' templates in my projects.

When I'm trying to bind events within template, as you recommend to do, it fails.

For example:

component.jade:

template(name="MyComponent")
  button(onClick=clickHappened)

component.coffee

class MyComponent extends BlazeComponent
   clickHappened: -> 1

When component renders, I get an error:

Error: Event handler not a function: 1

What happens, as far as I understand is that jade compiler executes 'clickHappened' method instead of passing it as an argument.

Is there any way (syntax?) to use Jade with BlazeComponents?

mitar commented 8 years ago

Yes, this is something @mquandalle should add to his compiler. Here is code for HTML files.

ciclopes commented 8 years ago

As far as it needs a function, have you tried clickHappened: -> -> 1? It may be a little bit ugly workaround, but it should work.

comerc commented 8 years ago

Hmm, blaze-magic-events works fine.

mitar commented 8 years ago

Because magic events seems to renders event handlers to DOM to define events. This is much uglier approach.