[blaze/htmljs/spacebars] create a html object and add the onClick function to it

88 views
Skip to first unread message

Michael Lazarski

unread,
Nov 25, 2014, 7:00:02 AM11/25/14
to meteo...@googlegroups.com
Hey,

basicly what i want to do is:
{{ myButton "hello" "#fff" "href" }}

this should create something like Hello and this should be added to the DOM. so far this part is working:

  Template.registerHelper("mBtn", function(text, color, href){
    var b = HTML.toHTML(HTML.BUTTON({"class":"ripple"}, text));
    return Spacebars.SafeString(b);
  });

my problem now is that i want to modify the onClick callback on that element because i want to add the material design click animation:
http://codepen.io/Craigtut/pen/dIfzv

is there a way to do that? or should i use a template instead ?

Avital Oliver

unread,
Nov 25, 2014, 9:35:27 PM11/25/14
to meteo...@googlegroups.com
Probably easier to do this in a template? You'd have to pass in options as keyword args though.

Usage:
{{> myButton text="hello" color="#fff" url="href" }}

Defining myButton:
<template name="myButton">
  <button class="ripple">text</button>
</template>

--
You received this message because you are subscribed to the Google Groups "meteor-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meteor-talk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/meteor-talk/4a3722f8-a4d4-401b-9951-66ed1cac5261%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Lazarski

unread,
Nov 27, 2014, 8:04:03 PM11/27/14
to meteo...@googlegroups.com
Hey Avital,

thx for the answer.

I thought maybe there would be a way to do it with helpers but i reworte everything to a template and it works fine.
Reply all
Reply to author
Forward
0 new messages