Search code examples
jquerykendo-uikendo-tooltip

Kendo UI Tooltip on show, access target?


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.


Solution

  • 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/