hovercard: fix hover-card does now working with ajax loaded content

This commit is contained in:
rabuzarus 2016-05-06 20:48:12 +02:00
parent 0ab7a210f9
commit 415c36e4bb

View file

@ -8,13 +8,10 @@
* *
*/ */
$(document).ready(function(){
// Elements with the class "userinfo" will get a hover-card. // Elements with the class "userinfo" will get a hover-card.
// Note that this elements does need a href attribute which links to // Note that this elements does need a href attribute which links to
// a valid profile url // a valid profile url
$('.userinfo').on("mouseover", function(e) { $("body").on("mouseover", ".userinfo", function(e) {
var timeNow = new Date().getTime(); var timeNow = new Date().getTime();
removeAllhoverCards(e,timeNow); removeAllhoverCards(e,timeNow);
var hoverCardData = false; var hoverCardData = false;
@ -81,7 +78,7 @@ $(document).ready(function(){
} }
} }
}, 500); }, 500);
}).on("mouseleave", function(e) { // action when mouse leaves the hover-card }).on("mouseleave", ".userinfo", function(e) { // action when mouse leaves the hover-card
var timeNow = new Date().getTime(); var timeNow = new Date().getTime();
// copy the original title to the title atribute // copy the original title to the title atribute
var title = $(this).attr("data-orig-title"); var title = $(this).attr("data-orig-title");
@ -89,11 +86,6 @@ $(document).ready(function(){
removeAllhoverCards(e,timeNow); removeAllhoverCards(e,timeNow);
}); });
});
// hover cards should be removed very easily, e.g. when any of these events happen // hover cards should be removed very easily, e.g. when any of these events happen
$('body').on("mouseleave touchstart scroll click dblclick mousedown mouseup submit keydown keypress keyup", function(e){ $('body').on("mouseleave touchstart scroll click dblclick mousedown mouseup submit keydown keypress keyup", function(e){
var timeNow = new Date().getTime(); var timeNow = new Date().getTime();