ItemView触发器会起泡吗?

编程入门 行业动态 更新时间:2024-10-24 21:20:10
本文介绍了ItemView触发器会起泡吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一张桌子的CompositeView.我在子项ItemView中为每一行设置了触发器...

I have a CompositeView for a table. I have triggers set in the child ItemView for each row...

var TableRow = Marionette.ItemView.extend({ tagName: "tr", template: _.template($(TableTemplates).filter('#tableRow').html()), triggers: { "click td": "click:td" } });

触发器是否应该出现在父级CompositeView上?

Are the triggers supposed to bubble up to the parent CompositeView?

来自文档 ...

具有访问这些[触发事件的视图的视图,模型和集合属性]的权限,可以更灵活地处理来自多个视图的事件.例如,选项卡控件或展开/折叠小部件(如面板栏)可以从许多不同的视图触发相同的事件,并可以通过单个功能进行处理.

Having access to these [the view, model, and collection properties of the view that triggered the event] allows more flexibility in handling events from multiple views. For example, a tab control or expand/collapse widget such as a panel bar could trigger the same event from many different views and be handled with a single function.

单个功能"是否不在父CompositeView中,以便它可以对任何子ItemViews的触发器做出反应? CompositeView如何侦听ItemView触发器?

Wouldn't the "single function" be within the parent CompositeView so that it can react to the triggers from any of its child ItemViews? How does the CompositeView listen for the ItemView trigger?

谢谢

推荐答案

是的,它们冒泡了.

唯一要记住的是,当从CompositeView或CollectionView调用ItemView时,该触发器将在名称前加上itemview,因此:

The only thing to have in mind is that when an ItemView is called from a CompositeView or CollectionView, that trigger will have itemview prepended in the name, so:

click:td将在CompositeView中作为itemview:click:td

该字符串可以像这样更改:

That string can be changed like this:

var CV = Marionette.CollectionView.extend({ itemViewEventPrefix: "some:prefix" });

所以您的触发器将是some:prefix:click:td

编辑:在较新的版本(不确定起始版本)上,前缀itemview已更改为childview

On newer versions (not sure about the starting version), the prefix itemview has been changed to childview

更多信息在这里:

木偶文档

更多推荐

ItemView触发器会起泡吗?

本文发布于:2023-10-22 08:24:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1516977.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:触发器   ItemView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!