i'd remove multiple specific elements array before displays. here code have results in none of elements being displayed:
$('[data-fancybox]').on('click', function() { var visiblelinks = $('.fancybox:visible'); $.fancybox.open( visiblelinks, { //options go here caption: function (instance, item) { var caption, link, collecttags, tags, filtertags, filteredtags; function format(tpl, binding) { if (typeof binding != 'function') return format(tpl, function (_, name) { return binding[name]; }); return tpl.replace(/\$(\w+)/g, binding); } caption = $(this).data('caption'); link = format('<br>see more pictures', item); collecttags = $(this).parent().attr("class").split(' '); function createtag(it) { return format("<a href='$site$it'>$it</a>", { site: (it == 'wedding' || == 'concert') ? 'http://example.com/gallery/#filter=.' : 'http://example.com/gallery/#filter=.', it: }); } filtertags = ['churchevent', 'corporate']; filteredtags = tags.filter(function(itm){return itm!== filtertags}); tags = $.map(collecttags, createtag); return [].concat(caption ? [caption, link] : link).concat(filteredtags.slice(1).join(', ')).join('<br>'); } }, visiblelinks.index( ) ); return false; });
i'm supposing that, since wrote "remove multiple specific elements" want remove filtertags.
if that's case change this:
filtertags = ['churchevent', 'corporate']; filteredtags = tags.filter(function(itm){return itm!== filtertags}); tags = $.map(collecttags, createtag); return [].concat(caption ? [caption, link] : link).concat(filteredtags.slice(1).join(', ')).join('<br>');
to this:
filtertags = ['churchevent', 'corporate']; tags = $.map(collecttags, createtag); filteredtags = tags.filter((item)=>{ for(tag in filtertags) if (item.indexof(filtertags[tag]) != -1) return false; return true; }); return [].concat(caption ? [caption, link] : link).concat(filteredtags.slice(1).join(', ')).join('<br>');
else use != -1 instead of == -1 in filter method.
Comments
Post a Comment