This is a migrated thread and some comments may be shown as answers.

Different style (margin) based on position setting

1 Answer 101 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 01 Nov 2013, 02:05 PM
I have a series of dynamically created tooltips that are initiated when clicking a small icon. The tooltips all have a default position of "right". To ensure that the tooltip doesn't cover the icon when opening I gave it a bit of a right margin to the outer div of 10px. For the vast majority of the tooltips it works perfectly.  The problem arises when the icon that you click is on the right side of the page, and the tooltip opens to the left of the icon because otherwise it would push off the screen (that I'm guessing is the default behavior). Unfortunatly, when it does open to the left of the icon it still takes on the margin setting and then completely covers the icon that you clicked to open it.

My question is how do I give anything that open on "position right" a different style than items defaulting to the "position left".  I've reviewed the Tooltip API, but don't see anything for a scenario like this.

Thanks,
J

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 01 Nov 2013, 02:53 PM
Hello Jason,

You can use the Tooltip's show event, locate the Tooltip's callout with

function onShow(e) {
   var callout = this.popup.wrapper.find(".k-callout");
}

... and find out the tooltip opening direction by examining the callout's second CSS class, which can be k-callout-w or k-callout-e in your scenario. In the latter case, remove the margin with Javascript.

P.S. Actually, you can directly try to find .k-callout-e and remove the margin if jQuery returns an element.

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ToolTip
Asked by
Jason
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or