Setting multiple positions for jQueryUI tooltips based on specific classes

I recently followed these instructions on utilizing jQueryUI tooltip to load content via ajax. (fiddle)(Full Screen). However, I encountered an issue where I'm unable to set a different position for the second tooltip (`.loadtip`) compared to the first one. Is there a way to override the position of the first tooltip?

Here is the code snippet:

   $(document).tooltip({
            items: "[data-info]",
            position: {
        my: "left+70 top",
        at: "center top",

    },
        content: function () {
            return $(this).data('info');
        },
        show: null, 
        close: function (event, ui) {
            ui.tooltip.hover(

            function () {
                $(this).stop(true).fadeTo(400, 1);
            },

            function () {
                $(this).fadeOut("150", function () {
                    $(this).remove();
                })
            });
        }
    });



    $('.loadtip').tooltip({

        position: {
            my: "right top",
            at: "center top-10"
        },

         content:function(callback) { 
    var loadfile = $('.loadtip').data("info");

           $.get(loadfile,{}, function(data) {
             callback(data); 
            });
           },


      });

Answer №1

If you want to customize the position of elements during initialization, you can easily do so. For example, if you have two classes named 'class-a' and 'class-b', you can set different positions for each class by following this code snippet:

$( ".class-a" ).tooltip({ position: { my: "left+30 center", at: "right center" } });

$( ".class-b" ).tooltip({ position: { my: "left+15 right", at: "right right" } });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Guidelines for accurately and appropriately creating divisions in JavaScript using mathematical principles

The program occasionally generates mathematically incorrect divisions, such as 2/0, and does not accept rounded answers like 0.33 or 0.33333 for "1/3". What modifications should I make to the code? Thank you for your assistance and time. document.getEl ...

Utilize jQuery to send and load double values efficiently

When attempting to load the initial .load, I am able to pass 1 variable without any issues. I receive this variable from a _GET method, store it in a data-id button attribute, and pass it back to another .load. In the second file, I once again receive the ...

Loading a gallery dynamically using AJAX in a CakePHP application

I am currently working with Cakephp 2.8.0 and I am facing an issue with implementing ajax in my application. I have a list of categories displayed as li links, and upon clicking on a category, I need to remove certain html code, locate the necessary catego ...

Using HTML5 input type number along with a regular expression pattern

In order to display only numbers and forward slashes in the input field with regex pattern, I attempted the following code: <input type="number" pattern="[0-9\/]*"> However, this code only shows the number pad from 0 to 9. How can I modify the ...

Storing data efficiently with Angular 2's local storage service

I am attempting to create a ToDoList using localstorage within a service. add.component.ts export class AddComponent implements OnInit { item: Item[]; constructor( private router: Router, private itemService: ItemService) { } ...

What is the best method for managing a JSON javascript post when encountering a 500 error?

When it comes to writing a JSON block, there are various methods one can use. Personally, I prefer the following approach: $.post('/controller', { variable : variable }, function(data){ if(data.status == '304') { // No chan ...

There was a lack of dynamic content on the webpage when using the view/template engine (Handlebars)

I'm currently using the Handlebars template engine in my project. Despite not encountering any errors in the console, I'm facing an issue with displaying dynamic content in the index.hbs file that is rendered from app.js. app.js const express = ...

Repeating Sprite Textures in THREEJS

I have a sprite and I am attempting to make the texture repeat continuously. Despite using what I believe are the correct settings, it doesn't seem to be working as expected. Is there something I am missing? Here is the outcome I am seeing: https:// ...

Guide on incorporating data from a text file into an HTML table

I'm attempting to showcase the records from upload.txt in an HTML table. The location of the upload.txt file is at this URL: http://localhost:3000/upload. When accessing this URL, it retrieves the upload.txt file. Currently, I am using node.js for r ...

Is it possible to initiate an ajax request depending on a php condition?

Awaiting page load... A PHP loop is set to display tier 1 data. Upon clicking tier 1, an AJAX call retrieves tier 2 data (HTML). Clicking on tier 2 initiates a second AJAX call for tier 3 data (HTML). All functions according to plan. The objective now ...

In Internet Explorer 8, the PNG image is visible but in IE7, it myster

I have been trying to showcase a logo (PNG created in Paint.NET) on my website (XHTML 1.0 Transitional), using the following code: <body> <div class="header"> <div class="logo"> <img src="logo.png" /> </div> ...

Using Bootstrap datepicker to show dates in Month YYYY format and then sending the data to server as MMYYYY for processing

Utilizing the bootstrap datepicker to select a date has been smooth sailing so far. However, due to certain server limitations, we now need to submit the data in the format "022021" rather than "Feb 2021". How can we achieve this post-formatting and submis ...

Having trouble showing images from block content using PortableText?

It's been quite a while now that I've been stuck on this issue. Despite being in a learning phase, I find myself unable to progress due to this specific problem. While links and text elements are functioning properly, I have encountered difficul ...

Error occurs when attempting to instantiate a class with parameters that do not match any available constructor signatures

I am attempting to encapsulate each instance of router.navigateByUrl within a class function, with the intention of calling that function in the appropriate context. However, I am encountering an error that states 'Supplied parameters do not match any ...

JavaScript Glitches

Embarking on the journey of web design and programming, I am venturing into the world of creating a simple gallery using JavaScript. Despite the convenience offered by jQuery, unfortunately, it is off-limits for this particular assignment. The challenge l ...

What is the best method to keep content confined within a box inside the grid, while also allowing the box to extend beyond the grid boundaries?

Apologies for the confusing title, but I must confess that I am unsure if there are more appropriate terms to explain what I am attempting to achieve. To provide clarity, I have included an image (as they say, a picture is worth a thousand words) https:// ...

`Is it more effective to define an array outside of a component or inside of a component in React?`

Exterior to a unit const somevalue = [1, 2, 3, 4, 5, 6]; const Unit = () => { return ( <div> {somevalue.map((value) => <span>{value}</span>)} </div> ); }; export default Unit; Interior to a unit const Unit ...

Response not being received by JQuery for POST request

While there are numerous posts discussing the same topic, none seem to be addressing my specific problem. I am currently utilizing jQuery's post method to retrieve a value from a database that matches the text entered in an input box. The expected re ...

fetch() operates successfully in Extension but encounters difficulties in Chrome Console/Snippet

I am currently facing an issue with my Chrome Extension. The extension performs a successful GET request, but when I try to replicate the same action in the Chrome Console or Snippets, I encounter errors. Here is a minimal example of the code I am using: f ...

Even after utilizing box sizing, additional margins are still contributing to the overall width calculation

Having an issue where the margin of my elements is affecting their total width, even with the box-sizing: border-box property in place. There are 2 elements - a sidebar and main content div - that stack neatly until margins are added and the sidebar moves ...