jQuery Pixastic unbind mouseleave

499 Views Asked by At

I've got a couple of functions going on, on some images that (using some code from this site) saturates (pixastic.revert) or desaturates an image when the mouse enters or leaves the image.

$('.execImagenav').live({
            mouseenter: function () {
                Pixastic.revert(this);
            }, mouseleave: function () {
                jQuery(this).pixastic("desaturate");
            }, click: function () {
                $('.execImagenav').unbind('mouseleave');
                Pixastic.revert(this);
            }
        });

I added the click bit at the bottom as when someone clicks an image, I don't want it to desaturate when the mouseleaves as this will be the 'active' image.

However this does not work, could you advise?

Thanks.

1

There are 1 best solutions below

0
On

I had the same problem. When you make your image desaturated, pixastic overwrites your tag with tag - jQuery seems to have problem with still treating this element as the same which you selected before (even if it has the same class, id, name etc). So if you want to select it again with jQuery you have to not use any "$(this)" expression or any variables containing your selector. In my case it works only if I select by $('.something').

Anyway I had some problems with 'real time' reverting images (or i.e. adding blur - it takes long time) and for me the best way to do something like this was to make function which duplicates all images and then desaturates duplicates and makes them undisplayed and next maintain hovers etc by events which shows/hides proper ersion of image...