Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle long click and right click events in Backbone JS

Tags:

backbone.js

We can manage click and double click events like below:

events: {
    "click .tree-toggler": "toggletree",
    "dblclick .doubleclick" : "doubleclickFunc"
  },

 toggletree: function(e){
     //code
  },
  doubleclickFunc : function(e){
      //code
  }

But I want to manage right click event and Long click event. How to handle them?

like image 760
Cindrella Avatar asked May 27 '13 11:05

Cindrella


1 Answers

I don't know about the "long click" event (I didn't even know there was one and can't find some doc on it), but anyway. Backbone uses jQuery's on method to bind your events to the DOM. That means anything that works with on will work with Backbone.View.events (unfortunately there are some limits to the selector you specify, but apart from that).

Try:

events: {
  contextmenu: 'onRightClick'
},
onRightClick: function() {
  alert('it works!');
}
like image 132
Loamhoof Avatar answered Sep 25 '22 00:09

Loamhoof