Ember:当点击其中的一个动作时防止链接到触发 [英] Ember: prevent link-to from firing when an action within it is clicked
问题描述
我有一个表格,我希望用户在单击一行时导航到特定项目,但该行可能包含触发操作但不触发导航的其他元素(例如复选框)(想想gmail).
I have a table where I want users to navigate to specific items when they click a row, but the row may contain other elements (such as checkboxes) that trigger actions but do not trigger navigation (think gmail).
我的结构是这样的:
{{#each player in controller}}
{{#link-to "player" player.uid tagName="tr"}}
<td>
{{input action="select" type="checkbox" checked=selected bubbles=false}}
</td>
<td>
{{player.name}}
</td>
...
{{/link-to}}
{{/each}}
我的问题是鄙视bubbles=false
(如spec),link-to
触发并导航到另一条路线.有什么想法吗?
My problem is that despise the bubbles=false
(as indicated in the spec), the link-to
fires and a navigate to another route. Any ideas?
推荐答案
当您将操作附加到元素时有效,输入助手不以这种方式支持 action='foo'
.它甚至根本没有被击中.
That works when you attach an action to an element, the input helper doesn't support action='foo'
in that manner. It isn't even being hit at all.
http://emberjs.jsbin.com/lugatite/1/edit
你需要滚动你自己的复选框,或者只是观察控制器中选中的值
You'll need to roll you're own checkbox, or just observe the checked value in your controller
App.MyCheckBox = Ember.Checkbox.extend(Ember.TargetActionSupport, {
target: Ember.computed.alias('controller'),
action: 'save',
actionContext: Ember.computed.alias('context'),
click: function(el) {
this.triggerAction();
el.stopPropagation();
}
});
http://jsbin.com/lugatite/5/edit
这篇关于Ember:当点击其中的一个动作时防止链接到触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!