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

Question: How to bind event handlers for custom events? #118

Closed JesperWe closed 8 years ago

JesperWe commented 8 years ago

The documentation for the new event handler bindings is a bit brief, and only use 'click' events in the examples, which are handled by binding with onClick. It would be helpful to document how to bind other events too. Can I always just capitalize the first letter and prepend "on", or what is the algorithm? For example, how would I bind the shown.bs.collapse event in Bootstrap?

mitar commented 8 years ago

Can I always just capitalize the first letter and prepend "on", or what is the algorithm?

Yes.

But I have not tried with dots in the name, though. But yes, everything which matches this regex is considered event handler, and then event name is generated here and attached with jQuery. So if dots are correctly parsed by Spacebars and if jQuery correctly attaches custom events, then it should work.

The issue is that I think jQuery uses dots for their namespacing of events, no?

mitar commented 8 years ago

Oh, those are namespaces what Bootstrap uses. So it should work.

mitar commented 8 years ago

Have you tried? Does it work?

JesperWe commented 8 years ago

Oh, sorry for not replying. Yes it works as you describe. Maybe worth adding a sentence to the documentation to describe the algorithm.

mitar commented 8 years ago

Do you want to propose a sentence? Pull request?

JesperWe commented 8 years ago

Done in #121

mitar commented 8 years ago

Perfect, thanks!