0

我有自定义绑定工作,有点:

http://jsfiddle.net/PTSkR/115/

弹出框有效,但内容是链接,而不是图像本身。如何让图像显示在弹出窗口中?

代码:

ko.bindingHandlers.bootstrapPopover = {
    init: function (element, valueAccessor, allBindingsAccessor, viewModel) {
        var options = valueAccessor();
        var defaultOptions = {trigger: 'hover'};
        options = $.extend(true, {}, defaultOptions, options);
        $(element).popover(options);
    }
};
var viewModel = {
    sideOneTextContent: ko.observable('<img src="https://si0.twimg.com/a/1339639284/images/three_circles/twitter-bird-white-on-blue.png" />')
}
ko.applyBindings(viewModel);
4

1 回答 1

1

您需要将 'html:true' 选项添加到元素绑定。请参阅您的 jsfiddle 的此更新

<a class="image-content-saved" href="#" data-bind="bootstrapPopover: { content: sideOneTextContent(), html:true }">
    <img src="http://www.dailydesigninspiration.com/diverse/adv/publicis/Omax-Wide-Angle-Lenses.jpg" />
</a>
于 2013-06-05T00:00:04.880 回答