How can I programmatically set the X and Y offset of a qTip2 tooltip?

355 views Asked by At

I can manually set the X and Y offset of a tooltip using the qTip API with numerical values, like this:

$(this).qtip('api').set({
        'position.adjust.x': 89,
        'position.adjust.y': 77
    });

But I can't do it programmatically, like this:

var offsetX = $(this).attr('data-tooltip-offsetX');
var offsetY = $(this).attr('data-tooltip-offsetY');

$(this).qtip('api').set({
    'position.adjust.x': offsetX,
    'position.adjust.y': offsetY
});

When I try that, the tooltips simply don't appear.

JSFiddle

Any thoughts or tips would be appreciated. Thanks!

Edit: Is it possible offset[ X | Y ] is being interpreted as a string instead of a number?

1

There are 1 answers

0
depperm On BEST ANSWER

You need to parse the string to an int like so:

var offsetX = parseInt($(this).attr('data-tooltip-offsetX'));

See fiddle