我怎样才能停止与Backbone.js的事件传播? [英] How can I stop event propagation with Backbone.js?

查看:250
本文介绍了我怎样才能停止与Backbone.js的事件传播?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

,说我要包括下列事件:

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

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

我怎样才能避免当我点击一个链接openPanel被解雇。我要的是有一个可点击的盒子​​,这将触发一个动作,但这个盒子可以有哪些应该触发其他操作,而不是父动作元素。想想例如Twitter.com,并在推文/右侧面板中的链接。

How can I avoid openPanel to be fired when I click on a link. What I want is to have a clickable box which will trigger an action, but this box can have elements which should trigger other actions, and not the parent action. Think for example Twitter.com, and links in Tweets/right hand panel.

推荐答案

我一直在使用 e.stopImmediatePropagation(); 为了从不断传播事件。我希望有一个较短的方式做到这一点。我想返回false;但是那是因为我熟悉的jQuery

I've been using e.stopImmediatePropagation(); in order to keep the event from propagating. I wish there was a shorter way to do this. I would like return false; but that is due to my familiarity with jQuery

这篇关于我怎样才能停止与Backbone.js的事件传播?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆