在coffeescript中使用meteor的Template..events api时,如何为.hover注册两个必需的函数?
我尝试了以下几点:
Template.<template>.events
'hover #elementID': (
(ev) -> console.log 'hello world'
(ev) -> console.log 'bye world'
)
答案 0 :(得分:11)
Saimeunt是正确的,但是如果你想要它完全像.hover()那么jquery会使用mouseenter和mouseleave。所以它是:
Template.<template>.events
"mouseenter #elementID": (event, template) ->
console.log "mousehover", event
"mouseleave #elementID": (event, template) ->
console.log "mouseout", event
&#13;
答案 1 :(得分:6)
正确的语法如下:
Template.myTemplate.events
"mouseover #elementID": (event, template) ->
console.log "mousehover", event
"mouseout #elementID": (event, template) ->
console.log "mouseout", event