Hammer JS does not work with the spine

I am trying to get spam jammer js events, but can't get it to respond to events. I have already tried the following.

http://cijug.net/tech/2013/01/16/backbone-hammer/

https://gist.github.com/kjantzer/4279025

I also put below code snippet in my opinion

initialize: function(){ this.events = _.extend({}, this.defaultEvents, this.events||{}); } 

JS Fiddle: http://jsfiddle.net/XcYhD/

the 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 make it work?

+6
source share
1 answer

You don't need a special events plugin, I would 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 the updated fiddle: http://jsfiddle.net/XcYhD/20/

+11
source

Source: https://habr.com/ru/post/913809/


All Articles