gpt4 book ai didi

knockout.js - 点击气泡 : false not working

转载 作者:行者123 更新时间:2023-12-04 10:48:12 24 4
gpt4 key购买 nike

我在 click 上的 KO 文档文章中遵循了这个示例。绑定(bind) here :

<div data-bind="click: myDivHandler">
<button data-bind="click: myButtonHandler, clickBubble: false">
Click me
</button>
</div>

我的代码如下所示:
<tr role="row" data-bind="click: 'True' === 'True' ? ($root.BrowsingCatalog() ? $root.viewProduct : $root.showProduct) : $root.showProduct">
<td class="col-sm-1" data-bind="visible: 'True' == 'True' ? !$root.BrowsingCatalog() : true">
<div class="btn-group">
<button type="button" data-bind="clickBubble: false" class="btn btn-round dropdown-toggle " aria-expanded="false">
<span class="fa fa-caret-down"></span>
</button>
</div>
</td>
</tr>

当我点击 button , 来自 tr 的事件被调用。我错过了什么?

最佳答案

我通过设置 data-bind="click: function() { }, clickBubble: false" 解决了它在我的 button .

显然,clickBubble没有 click不会工作。如果你想在整个元素上发生事件,除了某个子元素,设置 data-bind: "clickBubble: false"对 child 不起作用,您还需要为 click 指定绑定(bind),即使它只是一个空函数......

关于knockout.js - 点击气泡 : false not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36771792/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com