jtromans
jtromans

Reputation: 4273

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.

Upvotes: 3

Views: 8839

Answers (1)

Lars Höppner
Lars Höppner

Reputation: 18402

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/

Upvotes: 5

Related Questions