New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tooltip not shown properly the first time #111
Comments
Hello, that's because your images are not loaded when the tooltip opens the first time, so they have no size at that time (because you have not specified one in CSS). As a consequence, the tooltip adopts a size which is too small to contain the images when they have finished loading. On the other hand, when the tooltip opens for the second time, the images are already loaded and the tooltip adopts the right size. How to solve it :
|
Okay will try with the other options and update you, thanks for your time and effort :) |
Same trouble and solution#2 (replace contentHTML:true with $(html)) solve it, cool ! |
Hey @ludoo0d0a , can you please elaborate on your solution |
@ramswaroop read the 4th section of the documentation : Taking it a step further |
@ramswaroop
but
|
@ramswaroop A quick and easy (and nasty) fix is to load the images in a hidden div at the top of the page. |
Here is what worked for me: $('#ID').tooltipster({ contentAsHTML: true, functionReady: function(origin) { $('img').load(function(){ origin.tooltipster('reposition'); }); } }); |
I'm a bit lost on this and can't seem to figure it out... I'm experiencing the tooltip not showing the first time, but after the second time hovering it works fine. I've tried several of the solutions presented here, but to no avail. I have multiple thumbnails on my page and each is named chronologically (thumbnail1.jpg, thumbnail2.jpg, etc.). When a thumbnail is hovered over it should show a preview image unique to that thumbnail. Below is my code.
Note: I do specify an image width and height in my css class. Thanks for any help. |
Please instantiate Tooltipster at page load, not at mouseover. |
Ok, so maybe I'm trying to use Tooltipster in a way it wasn't meant to be used? I have many thumbnails dynamically loading onto a page. I want to show a larger preview on hover of what each thumbnail represents. But I don't want to manually put each tooltip html content the JS file in the header. That would be too complicated and my content changes each week. I'm automating. So I want to dynamically give the "content:" a different path to the larger preview image when hovering over each thumbnail. I almost had it working when instantiating on mouseover, but not 100%. By instantiating at page load I don't see how I can accomplish what I want. Any ideas? |
You are on the right track with your previous post. When you are hovering over the image for the first time, check out the path of the image in the tool tip. Is it it correct? Also, you can probably get rid of your span tag around the image in your tool tip as it is not needed. If none of these things will help, post a link to your page so I can check it out. |
@louisameline regarding my previous post, is there a downside to instantiate at mouseover vs page load (for my need)? Does mouseover break Tooltipster's functionality or is there another reason you advise not instantiating on mouseover? Thanks. |
@kevinhamil You should only need to instantiate the plugin once (at page load) - not every time you hover over an image. |
@mothermary I also face the same issue what @kevinhamil face. Googled and found the initializing Tooltopster on mouseover for the parent div and initializing it again and again. This is not an ideal solution. Then how can it be applied for future dynamically added elements? |
Actually when you "initialize it again", it's not initialized again. Nothing happens except for a warning in the console. There is no magic, you have to handle initializing things at the proper time by yourself (if you want to do things in a clean way). |
First initialize the plugin on page load. Then, if you want to change the content dynamically on mouseover, try these API methods: // return a tooltip's current content (if selector contains multiple origins, only the value of the first will be returned) $(...).tooltipster('content'); // update tooltip content $(...).tooltipster('content', myNewContent); So maybe you would do something like this: $('.item img').mouseover(function() { var source = $(this).attr('src'); $(this).tooltipster('content', source); }); |
Thanks @louisameline |
It does work but the listener must be on an img element. |
thanks for reply. but no success. i have a photo gallery when user hover over a thumbnail tooltipster shows real size image. server return this as response : <img class="json-img" scr="..." /> and tooltipster setting: $('.thumbnail').tooltipster({
.
.
.
success: function (data) {
// update our tooltip content with our returned data and cache it
origin.tooltipster('content', $( data)).data('ajax', 'cached');
}
.
.
.
});
$('.json-img').on('load', function(){
alert('hello');
$('.thumbnail').tooltipster('reposition');
}); every time an image is loaded via ajax no alert/no repositioning would run .so whats wrong with my code? |
Please review this page: http://stackoverflow.com/questions/3877027/jquery-callback-on-image-load-even-when-the-image-is-cached thanks |
thanks.after three days finally SOLVED
but an important note: dont forget to put |
This issue is now explained in the FAQ of the documentation. Thank you. |
Oddly enough I too was initially trying to achieve all this incorrectly during on.hover/mouseenter and figured I only needed to instantiate the Tooltipster once on
|
I have used tooltipster jquery plugin to create another jquery plugin called "ContentShare" but I am stuck with an issue.
Tooltipster fails to show the content properly for the first time when i call
$(element).tooltipster('show')
but from the second time onwards it works as it should.Go through this link for more understanding. Any help would be appreciated.
The text was updated successfully, but these errors were encountered: