【发布时间】:2010-08-10 13:16:24
【问题描述】:
我使用 .placeTaken 类将醉酒工具提示添加到 div。然后用户可以拖动框,因此我删除了该类并将其添加到新的 div 中。发生这种情况时,我向该 div 添加了一个新的提示工具提示,并且效果很好,但我想删除旧的提示。
他们说如果您希望通过将 title 属性设置为空字符串来删除工具提示,请改为设置 original-title 属性。我试过$("#"+dropFromId).attr("original-title", "");,但工具提示仍然存在。我什至无法通过设置另一个 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 />';
}
});
所以标题等于数组中的那个位置。我希望我解释得足够好。当盒子被放到一个新的地方时,会发生这种情况
$("#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 />';
}
});
}
});
这一切都很好,所以我认为我只需将 dropFromId 标题更改为 "" 在 drop 上,以便我将其删除。
【问题讨论】:
-
你能提供一些显示问题的示例代码吗?
-
您也应该发布您的 html,因为工具提示来自
title属性,除非您使用一些自定义属性。