We have a link in a table cell. When the user hover overs the link, an async RPC call is made and the hover text (the title attribute) is updated. We are seeing wildly inconsistent results with the hover text changing while the user is still hovered over the element. On some machines it works fine, on others not at all.
We cache the results so if the user triggers the hover again, the tooltip text is correctly displayed.
Is there a trick to updating the anchor’s title attribute while the user is still hovered over the anchor?
When the RPC call succesfully returns, we just call
link.setTitle(text);
which calls
/**
* Sets the title associated with this object. The title is the 'tool-tip'
* displayed to users when they hover over the object.
*
* @param title the object's new title
*/
public void setTitle(String title) {
if (title == null || title.length() == 0) {
DOM.removeElementAttribute(getElement(), "title");
} else {
DOM.setElementAttribute(getElement(), "title", title);
}
}
Your code here doesn say much about the problem.
setTitleworks wthout any issues no doubt. But firing an async call on mousehover is not so desirable as the issue you are facing here purely looks like originating because of time taken by the async call to complete.I would strongly suggest to prefetch the data that you need to show on mouseover, during the page load itself and set that text directly instead of an async call.