如何在backbonejs中实现触摸事件?

时间:2012-10-29 09:19:46

标签: backbone.js hammer.js

我需要在backbonejs View中实现基于触摸的事件。我试过锤子jquery特别活动,但它对我不起作用。

2 个答案:

答案 0 :(得分:2)

尝试使用支票移动设备扩展事件,并添加特定事件,例如

events: function() {
    return MOBILE ? 
       {
         "touchstart": 'select'
       } : 
       {
         "mousedown": 'select'
       }
  }

http://jsfiddle.net/dira/Ke2px/2/

正如我们从问题Backbone.js click event doesn't work with touch

中看到的那样

答案 1 :(得分:0)

将它用作jquery插件,然后通常使用events属性进行设置并在所需元素上侦听这些事件

events: {
    'tap': 'onTap',
    'hold .dragging-handle': 'onHold'
    // etc...
},

onTap: function(e) {
    // do whatever with the event data 
}