Javascript Tooltip / Posts /

Can we use this tooltip when we have x and y cordinate of the element

1
Hello ,
Thanks for tooltip.
I am using ajax tooltip . My problem is that using jquery I found the x and f coordinates  of the elemnet and want to show the tooltip based on these coordinates .
Is it possible .
My code is

function showMapTrialToolip(x,y){
              tooltip.ajax(this, "<?php echo $this->url(array('controller'=>'trial', 'action'=>'show-trial-popup'), 'default', true);?>/trial_id/"+id,null, {position:4});
               
            }
I want that tooltip will apper at position x and y
Thanks

Piyush Goyal  10 years ago   viewed: 3294    

2 Answers

1
If you want to position the tooltip not relative to the triggering element, you should set position to be 4, 5, or 6:
4: center
5: top left
6: bottom right

If choosing 4, the x, y will be the offset to the center;
If choosing 5, the x, y will be the offset to the top left of the screen;
If choosing 6, the x, y will be the offset to the bottom right of the screen.
Milo   10 years ago
0

Hello, 

To position the tooltip based on specific coordinates (x, y), you can modify the code to set the position option of the tooltip to the desired coordinates. Here's an example of how you can achieve this:

javascript

Copy

function showMapTrialToolip(x, y) {

  // Calculate the position of the tooltip based on the provided x and y coordinates

  var position = { top: y, left: x };


  // Set the position option of the tooltip to the calculated position

  tooltip.ajax(this, "<?php echo $this->url(array('controller'=>'trial', 'action'=>'show-trial-popup'), 'default', true);?>/trial_id/" id, null, { position: position });

}

minecraftle game

In this code, we first create an object called position with properties top and left representing the desired coordinates. We assign the provided x value to the left property and the provided y value to the top property.

Then, when calling the tooltip.ajax function, we pass this position object as the value for the position option. This will position the tooltip at the specified coordinates.

Make sure that the x and y values you pass to the showMapTrialToolip function are appropriate for the tooltip's positioning, considering the context and dimensions of the page.

johnsines
  27 days ago

   

Your name*
Password
(Optional. Used to modify this post afterwords)
+ =  

Ask your Own Question

  • If your question is related to the topic of this post, you can post your question to this page by clicking the "Post a reply" button at left;

  • When you want to start a new page for your question: