animate hover effect dissapears after filter in quicksand

668 Views Asked by At

I have a portfolio page with quicksand, which is working perfectly. To add some more fun, I added prettyPhoto to it, working perfectly too.

But now I added a hover effect to the images. It is working, but when I sort with the filter, the hover effect has gone. I don't even see it working in Firebug.

Loading .js files -> jquery, quicksand, prettyphoto and then the hover function. The php file (wordpress) looks like this:

<script type='text/javascript'>
    $(document).ready(function(){
        $("img").hover(
            function() {
                $(this).stop().animate({"opacity": "0.8"}, "slow");
            },
            function() {
                $(this).stop().animate({"opacity": "1"}, "slow");
            }
        );
    });
</script>

The rest of the php file:

<!-- #content BEGIN  -->
<div id="contentport" class="clearfix">
    <ul class="filter clearfix">
        <li><strong>Filter:</strong></li>
        <li class="active"><a href="javascript:void(0)" class="all">All</a></li>
        xxxx php magic xxxx
        <ul class="filterable-grid clearfix">
            xxxx php magic xxxx
            <li data-id="id-<?php echo $count; ?>" data-type="<?php foreach ($terms as $term) { echo strtolower(preg_replace('/\s+/', '-', $term->name)). ' '; } ?>">

                <?php 
                    // Check if wordpress supports featured images, and if so output the thumbnail
                    if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : 
                ?>

                <?php // Output the featured image ?>

                <a rel="prettyPhoto[gallery]" href="<?php echo $large_image ?>"><?php the_post_thumbnail('portfolio'); ?></a>                                   

                <?php endif; ?> 

                <?php // Output the title of each portfolio item ?>
                <p><a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a></p>

            </li>

            xxxx php magic xxxx
        </ul>
        xxxx php magic xxxx
</div>

I hope you have everything you need, I already looked at those links, but I really don't know what to do ... hover effect with quicksand plugin

jquery live hover

How to apply jQuery quicksand (sort) without losing a jQuery based portfolio hover?

jQuery quicksand plugin with .click method

Thanks in advance !

2

There are 2 best solutions below

0
On

Almost solved, for the jQuery, this code works. But the magnifying glass still doesn't work.

(function($){})(window.jQuery);

$(document).ready(function(){
    $('#contentport > ul > li').live('mouseenter', function(){
        $(this).find('img.attachment-portfolio').stop(true, true).animate({'opacity': '0.8'}, {duration:500});

    });

    $('#contentport > ul > li').live('mouseleave', function(){
        $(this).find('img.attachment-portfolio').stop(true, true).animate({'opacity': '1'}, {duration:500});                           
    });     

});
0
On

I'm not sure if this will help with your magnifying glass issue, but after suffering with some false starts on this problem myself (namely QuickSand killing my rollover functions), I found the solution for me was to specify the selector inside the .on() function call:

$(document).ready(function(){
    $('#contentport').on('mouseenter', 'ul li', function() {
        $(this).find('img.attachment-portfolio').stop(true, true).animate({'opacity': '0.8'}, {duration:500});

    });

    $('#contentport').on('mouseleave', 'ul li', function() {
        $(this).find('img.attachment-portfolio').stop(true, true).animate({'opacity': '1'}, {duration:500});                           
    });     

});

That seemed to solve the issue for me where simply using $('#contentport ul li').on('mouseenter', function() {... didn't work with the cloned elements.

Fingers crossed that's helpful.