Ember.js 在余烬中,如何防止属于包含元素的动作?
我使用的是Ember,我有一个用户可以点击的框,它会弹出一个包含更多信息的模式窗口 我在那个盒子上还有一个按钮,可以执行不同的操作 如果单击按钮,则会触发正确的操作,但它也会触发包含的Ember.js 在余烬中,如何防止属于包含元素的动作?,ember.js,Ember.js,我使用的是Ember,我有一个用户可以点击的框,它会弹出一个包含更多信息的模式窗口 我在那个盒子上还有一个按钮,可以执行不同的操作 如果单击按钮,则会触发正确的操作,但它也会触发包含的的操作。如何防止上的操作,同时允许上的操作 这是我的模板: <div {{action 'openModal' 'productResultOverview' this}} class="simpleproducttile"> <div class="row simpleproductti
的操作。如何防止
上的操作,同时允许
上的操作
这是我的模板:
<div {{action 'openModal' 'productResultOverview' this}} class="simpleproducttile">
<div class="row simpleproducttitle">
<p>{{ProductId}}<i class="icon-export helpiconleft"></i><img src="img/largebox.png"></img></p>
</div>
<div class="row simpleproductdescription">
<p>{{ProductDescription}}</p>
</div>
<div class="medium primary btn customizebutton">
<input type="submit" {{action "sendToSavedItems"}} value="Select and Customize"/>
</div>
</div>
操作openModal
包含在ApplicationRoute
中:
App.ApplicationRoute = Ember.Route.extend({
id: 'modal',
actions: {
openModal: function (modalName, model) {
console.log('opening modal', modalName, model);
return this.render(modalName, {
into: 'application',
outlet: 'modal',
model: model
});
},
//....
});
从:
默认情况下,{{action}
助手允许它处理的事件冒泡到父DOM节点。如果要停止传播,可以禁用对父节点的传播
您应该做的是将bubbles=false
添加到内部项:
<input type="submit" {{action "sendToSavedItems" bubbles=false}} value="Select and Customize"/>
这将阻止单击传播到父级
您可以添加控制器代码吗?我已经添加了代码。啊!太好了,就是这样。当我查看它时,我遗漏了几个词,认为冒泡是指:视图->控制器->路由
-类型冒泡。谢谢。是的,很容易混淆这两者,因为它们在概念上是相似的(当您能够回答时,不要忘记标记为已回答。:)
<input type="submit" {{action "sendToSavedItems" bubbles=false}} value="Select and Customize"/>