我们在表格单元格中有一个链接。当用户将鼠标悬停在链接上时,会进行异步RPC调用,并更新悬停文本(标题属性)。我们看到,当用户仍然悬停在元素上时,悬停文本更改的结果非常不一致。在某些机器上它工作正常,而其他机器则完全没有问题。GWT - 动态更改锚点标题
我们缓存结果,因此如果用户再次触发悬停,工具提示文本将正确显示。
当用户仍然悬停在锚点上时更新锚点的title属性是否有技巧?
当RPC调用成功地返回时,我们只需要调用
link.setTitle(text);
这就要求
/**
* 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);
}
}