I have this function here:
$("a.fancybox_vid").each(function(){
$(this).fancybox({
titleShow : false,
width: 640,
height: 395,
autoDimensions: false,
overlayOpacity: 0.6,
href: "misc/mc.php?v="+$(this).attr('id')
});
});
Now a link with c lass .fancybox_vid gets appended, and then this will not work. Only if it is there from the beginning. How can I have live() in this each().
If you want "live-like" functionality for methods, you can use the livequery
plugin:
$(function() {
$('a.fancybox').livequery(function() {
$(this).fancybox({
titleShow : false,
width: 640,
height: 395,
autoDimensions: false,
overlayOpacity: 0.6,
href: "misc/mc.php?v="+$(this).attr('id')
});
});
});
...although it would be better (less overhead) to just call the fancybox
plugin on the newly created elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With