Hovercard无法正常使用hoverfunction。 有任何想法吗?

我正在使用Hovercard,它与以下代码完美配合:

$.getJSON("userjson.php" function(result){ $('.user').hovercard({ showCustomCard: true, customCardJSON: result, openOnLeft: true }); }); 

在上面的代码中,我只是获取存储在当前使用cookie登录的用户数据库中的信息:

 $username = $_COOKIE['username']; $user_select = mysql_query("SELECT * FROM users WHERE username='$username'",$con); $user_array = mysql_fetch_array($user_select); $user = array( 'name' => "

".$user_array['username']."

", 'bio' => "


".$user_array['bio']."

", 'image' => "/pictures/users/".$user_array['propic'] ); echo json_encode($user);

但是,我想将当前登录用户的用户信息替换为名称正在hover的用户:

 $('.user').hover(function() { var obj = $(this); $.getJSON("userjson.php",{name: obj.text()}, function(result){ obj.hovercard({ showCustomCard: true, customCardJSON: result, openOnLeft: true }); }); }); 

这确实有效(在某种程度上)。 我必须将鼠标hover在名称上一次,然后再次将其显示出来,然后当我将鼠标移开时它不会消失。

这是我拍摄的2个video,以便您真正了解我在说什么:

使用登录用户的工作代码: http : //www.youtube.com/watch?v = FrWmOE-r8AA

不能使用hover用户名的代码: http : //www.youtube.com/watch?v = E9ksekpBnv0

我需要帮助!

hover卡不应在hover时添加,而是最初添加。

 $.each($(".user"), function() { var element = $(this); $.getJSON("userjson.php", {name: $(element).text()}, function(resp) { $(element).hovercard({ showCustomCard: true, customCardJSON: resp, openOnLeft: true }); }); });