Last active
August 29, 2015 14:06
-
-
Save isaacrankin/408eb9383afe43e4b33f to your computer and use it in GitHub Desktop.
Bind touch or mouse events in a Backbone view.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ExampleView = Backbone.View.extend({ | |
el: '.example', | |
events: function(){ | |
var action = (Modernizr.touch) ? 'touchend' : 'click', | |
events = {}; | |
events[ action + ' .btn'] = 'doSomething'; | |
return events; | |
}, | |
doSomething: function(e){ | |
window.alert('do something'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment