Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery Live with facebox plugin

I'm trying to use the jquery facebox plugin with live events (the official implemenatation, not the plugin).

My main page loads in a page via ajax. That remote page also has links to other remote pages which i would like to display in a popup dialog. I've been using the facebox plugin for this.

The below code doesn't work, and simply loads the remote page in to the viewport a a new page, not a popup.

<script type="text/javascript">
            jQuery(document).ready(function($) {

                $('a[rel*=facebox]').live("click", function() {
                    $('a[rel*=facebox]').facebox()
                });
            });
          </script> 

is this the correct way to use live events?

My development machine sadly consists of IE6 only[:(], so i can't use firebug to debug the code.

like image 355
MrBliz Avatar asked Apr 03 '26 00:04

MrBliz


1 Answers

complementing Kobi answer with fabrik comment:

$('a[rel*=facebox]').live("mousedown", function() { 
    $(this).unbind('click'); //everytime you click unbind the past event handled.
    $(this).facebox();
});

so, you can prevent facebox multiply the events.

credits to kobi.

like image 154
panchicore Avatar answered Apr 04 '26 14:04

panchicore



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!