jquerybackbone.jshoverintent

HoverIntent in a Backbone app


I'd like to use the HoverIntent jQuery plugin in a backbone event in the most concise way possible.

Here are the events (simplified for clarity):

events:
 'mouseenter'                      : 'onMouseEnter'
 'mouseleave'                      : 'onMouseLeave'

onMouseEnter: ->
  @$('.foo').show()      

 onMouseLeave: ->
  @$('.foo').hide() 

Basically, I don't want the herky-jerky showing and hiding as someone runs a mouse across the page, so HoverIntent seems to be the way to go. I've already included in my project and it's ready to go... but I'm not clear on how to properly invoke it in a backbone view. Suggestions?


Solution

  • There are some different versions of hoverintent that add custom events that you should be able to use in Backbone. Take a look at: https://github.com/LeMisterV/jquery.hoverintent. You should be able to use mouseenterintent and mouseleaveintent.