【发布时间】:2013-04-18 13:11:40
【问题描述】:
我正在尝试让锤子 js 事件与主干一起工作,但无法让它响应事件。 我已经尝试了以下方法..
http://cijug.net/tech/2013/01/16/backbone-hammer/
https://gist.github.com/kjantzer/4279025
我还把下面的代码放在了我的视图中
initialize: function(){
this.events = _.extend({}, this.defaultEvents, this.events||{});
}
JS 小提琴:http://jsfiddle.net/XcYhD/
代码
<div id="swiping"></div>
JS
AppView = Backbone.View.extend({
el: '#swiping',
events: {
'swipe': 'swipeMe'
},
render: function(){
this.$el.html('<h2>Swipe Me</h2>');
},
swipeMe: function(e){
alert('swiped ' + e.direction);
}
});
var view = new AppView();
view.render();
包含的库——hammer.js、jquery.specialevent.hammer.js 等。
无论如何让它工作?
【问题讨论】:
-
可能的重复/解决方案:stackoverflow.com/questions/16067989/….
标签: javascript backbone.js hammer.js