我正在努力让锤子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||{});
}
Run Code Online (Sandbox Code Playgroud)
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();
Run Code Online (Sandbox Code Playgroud)
包含的库 - hammer.js,jquery.specialevent.hammer.js等.
无论如何让它工作?