paynestrike
paynestrike

Reputation: 4658

Can Backbone views have two different events on a single html element

In my Backbone view can I bind multiple events to the same element?

events:{
      'click .app'    : 'appindex',
      'dblclick .app' : 'launchapp'
},

appindex: function() {
    alert(1);
},

launchapp: function() {
    alert(2);
}

After double clicking, it seems the launchapp method never fires. Could someone help me understand why?

Upvotes: 1

Views: 569

Answers (1)

Sergey Rybalkin
Sergey Rybalkin

Reputation: 3026

Your code snippet seems to be fine, so I think the problem is that appindex shows an alert box after the single click and doesn't allow you to do the double click. Try to replace it with a call to console.log(...). If that still doesn't help try to create a simple jsFiddle for others to test.

Upvotes: 1

Related Questions