I'm trying to get hammer js events working with backbone but can't get it to respond to events. I've tried the following already..
http://cijug.net/tech/2013/01/16/backbone-hammer/
https://gist.github.com/kjantzer/4279025
I've also put below piece of code in my view
initialize: function(){
this.events = _.extend({}, this.defaultEvents, this.events||{});
}
JS Fiddle : http://jsfiddle.net/XcYhD/
Code
<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();
Libraries Included - hammer.js , jquery.specialevent.hammer.js , etc..
Anyway to get it working ?
You don't need the special events plugin, I'd just go with the jquery plugin and then run the hammer()
function in your render.
render: function(){
this.$el.html('<h2>Swipe Me</h2>');
this.$el.hammer();
},
Here's an updated fiddle: http://jsfiddle.net/XcYhD/20/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With