javascript - Aftershow in fancybox jQuery -
i had same problem person: sharethis plugin not working in fancybox title have gotten work, except the
aftershow: function(){ stbuttons.locateelements(); } where in code should set it? i've tried many places, says error. say's placing wrong. should place in script below?
<script type="text/javascript"> $(document).ready(function(){ $(".fancybox").fancybox({ beforeshow: function() { var caption = $(this.element).data("caption") ? $(this.element).data("caption") : ""; this.title = this.title ? this.title + buildsharethis(this.href) + caption : buildsharethis(this.href) + caption; if (this.title) { '' // new line this.title += '<br />'; } }, nexteffect : 'fade', preveffect : 'fade', padding : 0, margin : [15, 15, 50, 15], afterload : addlinks, beforeclose : removelinks }); function buildsharethis(url){ var customsharethis = "<div class='share'>"; // class styling maybe customsharethis += "<span class='st_facebook_hcount' displaytext='facebook' st_url='"+url+"'></span> "; customsharethis += "<span class='st_twitter_hcount' displaytext='tweet' st_url='"+url+"'></span>"; customsharethis += "<span class='st_pinterest_hcount' displaytext='pinterest' st_url='"+url+"' st_img='"+url+"' ></span>"; customsharethis += "<span class='st_tumblr_hcount' displaytext='tumblr' st_url='"+url+"'></span>"; customsharethis += "</div>"; homecoming customsharethis; } function addlinks() { var list = $("#links"); if (!list.length) { list = $('<ul id="links">'); (var = 0; < this.group.length; i++) { $('<li data-index="' + + '"><label></label></li>').click(function() { $.fancybox.jumpto( $(this).data('index'));}).appendto( list ); } list.appendto( 'body' ); } list.find('li').removeclass('active').eq( this.index ).addclass('active'); } function removelinks() { $("#links").remove(); } }); </script>
you can set fancybox api options, including fancybox callbacks (afterload, aftershow, beforeclose, etc.) :
$(".fancybox").fancybox({ nexteffect: 'fade', preveffect: 'fade', padding: 0, margin: [15, 15, 50, 15], afterload: addlinks, aftershow: function () { stbuttons.locateelements(); }, beforeclose: removelinks }); assuming have defined addlinks , removelinks functions somewhere else in script.
javascript jquery fancybox share
No comments:
Post a Comment