Kendo UI Tooltip remove/destroy?

jtromans picture jtromans · Nov 20, 2013 · Viewed 13.2k times · Source

How do I remove/destroy an existing tooltip created like:

$(td[role=gridcell]").kendoTooltip({ ... });

For example, to destroy a grid you do the following:

$("#grid").data("kendoGrid").destroy();

How do I check whether the tooltip exists and/or has been destroyed?

Answer

Lars Höppner picture Lars Höppner · Nov 20, 2013

While the documentation doesn't list a destroy method for kendoToolTip, it does exist.

I would suggest creating your Tooltip like this instead:

$("#grid").kendoTooltip({
    filter: "td[role=gridcell]",
    content: "My Other ToolTip"
});

Then you can destroy the Tooltip with

$("#grid").data("kendoTooltip").destroy();

If you create it like this:

$("td[role=gridcell]").kendoTooltip({ ... });

it will create a widget for each cell (because your jQuery selector selects all cells!), so when you try do this:

var myTooltip = $("td[role=gridcell]").data("kendoTooltip");
myTooltip.destroy();

it will only return and destroy the widget for the first of the matched elements.