作者:cecillalurw_689 | 来源:互联网 | 2023-01-31 12:38
Iaddthetipsytooltiptodivswiththe.placeTakenclass.Theusercanthendragboxesaround,so
I add the tipsy tooltip to divs with the .placeTaken class. The user can then drag boxes around, so I remove the class and add it to a new div instead. When this happens, I add a new tipsy tooltip to that div and that works fine, but I want to remove the old one.
我使用.placeTaken类将divy工具提示添加到div。然后用户可以拖动框,所以我删除了类并将其添加到新的div中。当发生这种情况时,我向该div添加了一个新的醉意工具提示,并且工作正常,但我想删除旧的。
They say if you wish to remove the tooltip by setting the title attribute to an empty string, set the original-title attribute instead. I tried $("#"+dropFromId).attr("original-title", "");
but the tooltip is still there. I can't even change the tooltip title by setting another original-title.
他们说如果您希望通过将title属性设置为空字符串来删除工具提示,请改为设置original-title属性。我试过$(“#”+ dropFromId).attr(“original-title”,“”);但工具提示仍在那里。我甚至无法通过设置另一个原始标题来更改工具提示标题。
What am I doing wrong?
我究竟做错了什么?
Edit: I guess I didn't give you guys enough information. I use ajax to grab the places that are taken from the database. The PHP returns an associative array (customers) that I then use in my Javascript where the taken place matches a name. The places that are taken changes when dropping, so I perform the ajax function again to update the array with all the taken places. At fist, I add the tipsy tooltip to all the taken places like so
编辑:我想我没有给你们足够的信息。我使用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 ''+customers[id]+'
';
}
});
So the title is equal to what matches that place in the array. I hope that I am explaining this good enough. When the box is dropped in a new place, this is what happens
所以标题等于数组中匹配的位置。我希望我能够解释这个问题。当盒子放在一个新的地方时,就会发生这种情况
$("#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 ''+customers[id]+'
';
}
});
}
});
This all works fine, so I thought that I'd simply change the dropFromId title to "" on the drop, so that I remove it.
这一切都很好,所以我认为我只需将DropFromId标题更改为“”,以便我删除它。
9 个解决方案
0
I recently had this issue, here's how I resolved it:
我最近有这个问题,这是我如何解决它:
Use this to set the original-title attribute to 'stop':
使用此选项将original-title属性设置为“stop”:
$('.myElement').attr('original-title','stop');
Then, in jquery.tipsy.js, change the code to the following:
然后,在jquery.tipsy.js中,将代码更改为以下内容:
...
} else if (typeof opts.title == 'function') {
title = opts.title.call(this);
}
if (title != 'stop') { //line 32
...
...
} //line 62
...
In my release (0.1.7) the added code starts at line 32 and ends bracket at line 62. Tipsy should see that your title attribute equals 'stop' and wont try to open the tooltip.
在我的发布(0.1.7)中,添加的代码从第32行开始,在第62行结束括号.Thisy应该看到你的title属性等于'stop'并且不会尝试打开工具提示。
Also, this spits out some error to the console. It doesn't make any difference, but if you want to get rid of it, add this at line 73 (after adding previous code)
此外,这会向控制台吐出一些错误。它没有任何区别,但是如果你想摆脱它,在第73行添加它(在添加以前的代码之后)
try { tip.remove(); } catch(err){}
POW