How can I stop event propagation with Backbone.js?

前端 未结 5 1102
面向向阳花
面向向阳花 2021-01-31 16:01

Using a Backbone.js View, say I want to include the following events:

    events: {
        \'click a\': \'link\', 
        \'click\': \'openPanel\' 
    }
         


        
5条回答
  •  广开言路
    2021-01-31 16:14

    Each of your event handlers will be passed an event object when it's triggered. Inside your handler, you need to leverage jQuery's event.stopPropagation() method. For example:

    link: function(event) {  
      //do some stuff here
      event.stopPropagation();
    }
    

提交回复
热议问题