I have the following code in my page:
<script type = "text/javascript">
$(document).ready(function() {
// Fancy LightBox
$("a[rel=group]").fancybox({
'transitionIn' : 'elastic',
'changeFade' : 'fast',
'transitionOut' : 'elastic',
'titlePosition' : 'over',
'overlayOpacity' : '0.6',
'showCloseButton' : false,
'overlayColor' : '#000000',
'titleFormat' : function(title, currentOpts) {
return '<span id="fancybox-title-over">'+ (title.length ? ' ' + title : '') + '</span>';
}
});
});
</script>
But when there is not an element with rel=group
it crashes my Concrete5 dashboard panel. Is there a way to check if the element with rel=group
exists and if it does not, DONT fire the code?
Try
if($('a[rel="group"]').length > 0)
{
$('a[rel="group"]').fancybox({