2

I know that there are people ask kendo to prevent kendo tooltip from close/hide whenever we click outside the tooltip. They are suggesting it here but seems that it has not been implemented yet.

I couldn't find the method which closes/hides when we click outside kendo tooltip so far. I only found the event triggered when we click on close or cancel button on kendo tooltip. But is there any way/hackish way to achieve this using javascript/jquery/anything?

4

2 回答 2

1

就像您在链接中看到的那样,autoHide: false当您:

  • 在工具提示之外单击
  • 滚动页面
  • 按 Esc

在 Telerik 不会实现阻止它的功能之前,唯一的方法是使用 jquery event.stopImmediatePropagation()。例如,当您在外部单击时阻止隐藏提示音,您可以编写:

$("#target").kendoTooltip({
    autoHide: false
});
$('html').on('mousedown', function(e){
    e.stopImmediatePropagation();
});

工作演示:http ://dojo.telerik.com/ugUCI

不幸的是,它会阻止任何html onmousedown 事件,例如 DropDownLists/ComboBoxes 隐藏等。

于 2015-01-20T11:15:40.143 回答
0

您可以覆盖 kendo UI 弹出类的关闭函数以阻止执行。我的解决方案是在“隐藏”处理程序中抛出一个自定义异常,并防止在捕获此自定义异常时发生关闭。

kendo.ui.Popup.fn.close = function (close) {
    return function (skipeffects) {
        try {
            close.call(this, skipeffects);
        } catch (err) {
            // suppress error if its the right type
            if (!(err instanceof PreventTooltipHideException)) {
                throw err;
            }
        }
    }
}(kendo.ui.Popup.fn.close);


var tooltip = $('#' + areaId).kendoTooltip({
    content: "Hello World!",
    hide: function (e) {
         throw new PreventTooltipHideException();
    },
    autoHide: false
});
于 2015-09-21T17:04:19.443 回答