I have a mouseover function and opposite mouseout function attached to images on my page to bring up a larger version when they're hovered over. The functions are attached to the image elements via livequery.
The problem is that it appears my functions have been attached to every element on the page, not just the images I want them to be attached to. If I put a console.log
into the function I'll see it print any time I mouse in or out of any element on the page.
Any ideas why livequery is binding to so many things?
Here's the code:
Assets.registerPopups = function(selector, context) {
var targets = jQuery(selector, context);
targets.livequery("mouseover", function(e) {
console.log("mouseover e.target", e.target);
});
targets.livequery("mouseout", function(e) {
console.log("mouseout e.target", e.target);
});
};
jQuery(function(){
Assets.registerPopups(".photo, .video, .flash, .h264", "#controller.project_assets.index")
});
Note: This is a poorly maintained project I inherited so I'm dealing with jQuery 1.2.6 and livequery 1.0.2. I'm in the process of trying to upgrade it.