悬停功能无法正确使用悬停功能。有任何想法吗? [英] Hovercard not working correctly with the hover function. Any ideas?
问题描述
$。getJSON(userjson.php
函数(结果){
$('。user')。hovercard({
showCustomCard:true,
customCardJSON:result,
openOnLeft:true
});
});
在上面的代码中,我只是将存储在用户数据库中的信息目前使用cookies登录:
$ username = $ _COOKIE ['username'];
$ user_select = mysql_query(SELECT * FROM users WHERE username ='$ username',$ con);
$ user_array = mysql_fetch_array($ user_select);
$ user = array(
'name'=>< p style = \text-align:left; text-decoration:underline; \> 。$ user_array ['username']。< / p>,
'bio'=>< p style = \text-align:left \>< br> 。$ user_array ['bio']。< / p>,
'image'=>/pictures/users/\".$user_array['propic']
);
echo json_encode($ user);
但是,我想将当前登录用户的用户信息替换为名称为:
$ p $ $('。user')。hover(function(){
var obj = $ (this);
$ .getJSON(userjson.php,{name:obj.text()},
function(result){
obj.hovercard({
showCustomCard:true,
customCardJSON:result,
openOnLeft:true
});
});
});
这确实有效(在某种程度上)。我必须将鼠标悬停在名称上,然后再次显示,然后当我将鼠标移开时它不会消失。
这里有两个视频我采取了这样的做法,让你真正了解我在说什么:
使用登录用户的工作代码: http://www.youtube.com/watch?v=FrWmOE-r8AA
不使用隐藏用户名的工作代码: http://www.youtube.com/观看?v = E9ksekpBnv0
需要帮助!
悬停卡不应该在悬停时添加,但最初。
$ b $
$。each($(。user),function(){
var element = $(this );
$ .getJSON(userjson.php,{name:$(element).text()},function(resp){
$(element).hovercard({
showCustomCard:true,
customCardJSON:resp,
openOnLeft:true
});
});
});
I am using Hovercard and it works perfectly with the following code:
$.getJSON("userjson.php"
function(result){
$('.user').hovercard({
showCustomCard: true,
customCardJSON: result,
openOnLeft: true
});
});
In the code above i am just taking the information that is stored in the database of the user that is currently logged in using cookies:
$username = $_COOKIE['username'];
$user_select = mysql_query("SELECT * FROM users WHERE username='$username'",$con);
$user_array = mysql_fetch_array($user_select);
$user = array(
'name' => "<p style=\"text-align:left; text-decoration:underline;\">".$user_array['username']."</p>",
'bio' => "<p style=\"text-align:left\"><br>".$user_array['bio']."</p>",
'image' => "/pictures/users/".$user_array['propic']
);
echo json_encode($user);
However, I want to replace the user information from the current logged in user to the user who's name is being hovered over:
$('.user').hover(function() {
var obj = $(this);
$.getJSON("userjson.php",{name: obj.text()},
function(result){
obj.hovercard({
showCustomCard: true,
customCardJSON: result,
openOnLeft: true
});
});
});
This does work (to some extent). I have to hover over the name once and then another time for it to show and then it does not go away when i take the mouse away..
Here are 2 videos i took so that you actually have an idea about what I'm talking about:
Working code taking the logged in user: http://www.youtube.com/watch?v=FrWmOE-r8AA
Not working code taking the hovered username: http://www.youtube.com/watch?v=E9ksekpBnv0
I NEED HELP!
The hover card should not be added upon hover but initially.
$.each($(".user"), function() {
var element = $(this);
$.getJSON("userjson.php", {name: $(element).text()}, function(resp) {
$(element).hovercard({
showCustomCard: true,
customCardJSON: resp,
openOnLeft: true
});
});
});
这篇关于悬停功能无法正确使用悬停功能。有任何想法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!