peerlibrary/meteor-blaze-components

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

neoromantic opened this issue · 4 comments

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

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

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

Hmm, blaze-magic-events works fine.

mitar commented

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