使用Knockout.js绑定Bootstrap的popover中的单击

时间:2021-11-20 20:37:02

I have an issue binding click of element that located within Bootstrap's popover.

我有一个问题绑定点击位于Bootstrap的popover内的元素。

Html

<a href="#" id="open-popover-link">Open popover</a>

<div id="popover-content" class="hide">
<a href="#" data-bind="click: Click">Click Me!</a>
</div>

Knockout

 function Model() {
        var self = this;
        self.Click = function () {
            alert('Works!');
        }

For some reason this doesn't work, but if I move tag out of popover, it works. Where is the problem here?

由于某种原因,这不起作用,但如果我将标签移出popover,它就可以工作。这里的问题在哪里?

1 个解决方案

#1


0  

Widgets generally have their own ways of modifying the DOM. For such things, you need Custom Binding Handlers. There are a number of binding handlers that have already been written for commonly-used widgets like jQuery-UI and Bootstrap.

小部件通常有自己的修改DOM的方法。对于这样的事情,您需要自定义绑定处理程序。有许多绑定处理程序已经为jQuery-UI和Bootstrap等常用小部件编写。

Knockstrap is a collection of binding for Bootstrap widgets (including the popover).

Knockstrap是Bootstrap小部件(包括popover)的绑定集合。

#1


0  

Widgets generally have their own ways of modifying the DOM. For such things, you need Custom Binding Handlers. There are a number of binding handlers that have already been written for commonly-used widgets like jQuery-UI and Bootstrap.

小部件通常有自己的修改DOM的方法。对于这样的事情,您需要自定义绑定处理程序。有许多绑定处理程序已经为jQuery-UI和Bootstrap等常用小部件编写。

Knockstrap is a collection of binding for Bootstrap widgets (including the popover).

Knockstrap是Bootstrap小部件(包括popover)的绑定集合。