Skip to content

Instantly share code, notes, and snippets.

@yoannmoinet
Last active August 29, 2015 14:05
Show Gist options
  • Save yoannmoinet/d2dfd2f5dd3be37140cc to your computer and use it in GitHub Desktop.
Save yoannmoinet/d2dfd2f5dd3be37140cc to your computer and use it in GitHub Desktop.
Events for a mobile/desktop Backbone application.
Backbone.MOBILE = navigator.userAgent.match(/mobile/i);
var View = Backbone.View.extend({
events: function () {
return Backbone.MOBILE ? {
"click .new_message": "newMessageClick",
"touchstart #send_new_message": "openMenu",
"touchend #send_new_message": "selectMenu"
} : {
"click .new_message": "newMessageClick",
"mousedown #send_new_message": "openMenu",
"mouseup #send_new_message": "selectMenu"
};
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment