positioning jQuery tooltip
Asked Answered
U

3

10

I'm trying to customise the positioning of my tooltips, using jQuery UI Tooltip and this code:

$(".karma").tooltip({
  position: {
    my: "center bottom",
    at: "right top"
  }
});

But whatever I do to "my" and "at" nothing changes. What am I doing wrong?

Here is the link to the jQuery Tooltip API position section

Ultrasonic answered 7/3, 2013 at 18:10 Comment(0)
A
4

There is nothing wrong with your code. However, without seeing your HTML, it is hard to say why it isn't working.

Make sure you have loaded jQueryUI script: here. Also make to wrap your code with $(document).ready(). Let me know if you have any other questions.

DEMO: http://jsfiddle.net/dirtyd77/SLGdE/16/

Alboin answered 7/3, 2013 at 20:39 Comment(2)
Well, I'm using rails and the assets pipeline is enabled, and I have these lines in my application.js. //= require jquery //= require jquery_ujs //= require jquery-ui. And it is wrapped inside document readyUltrasonic
The relevant part of my html code looks like this: <p class="karma" data-original-title="tooltip test">Karma score</p>Ultrasonic
F
3

If you got here because your positioning addition wasn't working (e.g. at: "right + 10"), then the solution is to remove any spaces around the operator.

Change at: "right + 10" to at: "right+10", and it should work.

Forgather answered 24/7, 2015 at 17:1 Comment(0)
D
0

You can try this:

    my: "left-25 bottom", 
    at: "center"
Defecate answered 14/1, 2016 at 15:43 Comment(1)
Thanks for posting an answer to this question! This answer is very short though and doesn't provide much context. Please explain some of the reasoning behind it, and it will become much more useful for the asker and future readers. Thanks!Illusionism

© 2022 - 2024 — McMap. All rights reserved.