Kendo UI Tooltip on show, access target?

jtromans picture jtromans · Nov 21, 2013 · Viewed 8.4k times · Source

The target is accessible by passing the argument e to the anonymous function for content.

gridToolTipz = $('#grid').kendoTooltip({ 
    filter: "td[role=gridcell]",
    content: function (e) {
            var target = e.target; // the element for which the tooltip is shown
            ...
    },
    show: function(e) {
            var target = e.target; // the element for which the tooltip is shown
            ...
    }
});

Is it possible to achieve the same thing on show? The above code doesn't work.

Answer

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

You can always access the target element by calling tooltip.target():

var toolTip = $('#grid').kendoTooltip({
    filter: "td[role=gridcell]",
    content: function (e) {
        var target = e.target; // the element for which the tooltip is currently shown
        return "Content is: " + target.text(); // use current element for content
    },
    show: function (e) {
        var target = this.target(); // the element for which the tooltip is currently  shown

        if (target) {           
            console.log("now showing with content: ");
            console.log(target.text());
        }
    }
}).data("kendoTooltip");

See demo: http://jsfiddle.net/lhoeppner/mcpxj/