I have a tooltip on an anchor element, that sends an AJAX request on click. This element has a tooltip (from Twitter Bootstrap). I want the tooltip content to change when the AJAX request returns successfully. How can I manipulate the tooltip after initiation?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
The following worked the best for me, basically I'm scrapping any existing tooltip and not bothering to show the new tooltip. If calling show on the tooltip like in other answers, it pops up even if the cursor isn't hovering above it.
The reason I went for this solution is that the other solutions, re-using the existing tooltip, led to some strange issues with the tooltip sometimes not showing when hovering the cursor above the element.
I'm using this easy way out:
You can set content on tooltip call with a function
You don't have to use only the title of the called element.
Destroy any pre-existing tooltip so we can repopulate with new tooltip content
With Tooltip object Boostrap :
In bootstrap 4 I just use
$(el).tooltip('dispose');
then recreate as normal. So you can put the dispose before a function that creates a tooltip to be sure it doesn't double up.Having to check the state and tinker with values seems less friendly.