Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call .hover from Template.<template>.events api in coffeescript

How do you register the two required functions for .hover when using meteor's Template..events api in coffeescript?

I'm trying something along the lines of:

Template.<template>.events
  'hover #elementID': (
     (ev) -> console.log 'hello world'
     (ev) -> console.log 'bye world'
   ) 
like image 969
John Cast Avatar asked Jan 22 '15 00:01

John Cast


2 Answers

Saimeunt's is correct, but if you want it to be exactly as .hover() jquery uses mouseenter and mouseleave instead. So it'd be:

Template.<template>.events
  "mouseenter #elementID": (event, template) ->
    console.log "mousehover", event
  "mouseleave #elementID": (event, template) ->
    console.log "mouseout", event
like image 86
Nick Lammertyn Avatar answered Nov 06 '22 00:11

Nick Lammertyn


The correct syntax is something like :

Template.myTemplate.events
  "mouseover #elementID": (event, template) ->
    console.log "mousehover", event
  "mouseout #elementID": (event, template) ->
    console.log "mouseout", event
like image 41
saimeunt Avatar answered Nov 06 '22 00:11

saimeunt