[fixed] Javascript work when alert inside

I was working with the tooltip, and have to show image inside the tooltip instead of text. I was using jquery datatable and by default there is feature of show tooltip on hover icon. But I have to show image instead of text using ajax.

I got a javascript library to implement the tooltip on hover of icon. But I have to get image path from the server using ajax. I put the code to get it work but there was a problem, it works only when there is a alert inside the method. I did a lot of research some say add timeout or blah blah, but after spend a day I got the solution next day.

It’s not working due to tooltip javascript library wasn’t initialize on document ready function. I put the initializer function on the windows.laod() instead of document.ready() and it worked like charm. You have to put you method or code inside of window load mehtod like below :-

// starting the script on page load
window.onload = function () {
    fntoolTip();
}
fntoolTip= function () {
//do whatever you want
};

Hope it will work for you guys too, If it helps then don’t forgot to comment.

Happy Coding……..

Posted by | View Post | View Group