我使用.placeTaken类将divy工具提示添加到div.然后用户可以拖动框,因此我删除了类并将其添加到新的div中.当发生这种情况时,我向该div添加一个新的醉意工具提示,并且工作正常,但我想删除旧的.
他们说如果您希望通过将title属性设置为空字符串来删除工具提示,请改为设置original-title属性.我试过$("#"+dropFromId).attr("original-title", "");
但工具提示仍在那里.我甚至无法通过设置另一个原始标题来更改工具提示标题.
我究竟做错了什么?
编辑:我想我没有给你们足够的信息.我使用ajax来获取从数据库中获取的位置.PHP返回一个关联数组(客户),然后我在我的JavaScript中使用,其中所发生的匹配名称.删除时所采取的位置会发生变化,因此我再次执行ajax函数以使用所有拍摄的位置更新数组.首先,我将醉意的工具提示添加到所有拍摄的地方,如此
$("#map div.placeTaken").tipsy({gravity: 'w', html: true, fade: true, title:
function(){
// id could for example be map74, substring to 74
var id = $(this).attr("id").substring(3,6);
return '<div>'+customers[id]+'</div><br />';
}
});
Run Code Online (Sandbox Code Playgroud)
所以标题等于数组中匹配的位置.我希望我能够解释这个问题.当盒子掉到一个新的地方时,就会发生这种情况
$("#map div span").bind( "dragstop", function(event, ui) {
// some code here to change the .placeTaken class
// update database with the new place
$.ajax({
type: "POST",
url: "map.php",
data: "dropFromId="+ dropFromId.substring(3,6) +"& dropToId="+ dropToId.substring(3,6),
success: function(){
// ajax function to update the js array with new places
customerTooltip();
}
});
// on this place, add tooltip
$("#"+dropToId).tipsy({gravity: 'w', html: true, fade: true, title:
// funktion för att avgöra vilken title som ska användas
function(){
var id = dropToId.substring(3,6);
return '<div>'+customers[id]+'</div><br />';
}
});
}
});
Run Code Online (Sandbox Code Playgroud)
这一切都很好,所以我认为我只需将DropFromId标题更改为"",以便我删除它.
iwa*_*bed 26
使用$(".tipsy").remove();
似乎可以解决问题,因为tipsy
当显示工具提示时,带有类的div 将附加到doc的主体.
请确保你不在tipsy
其他地方使用类(即调用你的工具提示之类的东西toolTip
)
如果你不想再使用tipsy就可以.tipsy('disable')
在元素上使用了.
如果你正在使用trigger: manual
而你想要隐藏它,你可以删除.tipsy
身体上的div.
还有disable
enable
和toggleEnabled