简体   繁体   中英

Facebook Recommendations Bar and dynamic content?

OK I have a portfolio at http://www.gablabelle.com/ . When you click a thumbnail a slide (of a slider) comes in with the requested photo. Great.

I have the Facebook Recommendations Bar installed as you can see in the lower right corner. I want the Like button to be linked to slide I am on at that specific moment.

A simplified version of the code:

slider.ev.on('SlideChange', function(event) {
// Show me the URL, works fine
    console.log(href);
// Trying to change the URL of the Facebook Recommandations Bar plugin
    $(".fb-recommendations-bar").attr("data-href", href);
// The trigger
    FB.XFBML.RecommendationsBar.markRead(href);
});

The HTML:

<div id="social" class="hide">
    <div class="fb-recommendations-bar" data-href="http://www.facebook.com/gablabellephoto" num_recommendations="0" data-trigger="manual" data-site="http://www.gablabelle.com/"></div>
</div>

The Facebook documentation says the followings:

https://developers.facebook.com/docs/reference/plugins/recommendationsbar/

manual - use this option to manually trigger the plugin. When you want to trigger the plugin, call FB.XFBML.RecommendationsBar.markRead(href); in JavaScript. The href parameter is optional and will default to the current page if not set. If provided, it must match the href parameter on the XFBML tag. The manual trigger is useful when you have more a multi-page article. For example on a three page article, you would add trigger="manual" on pages one and two and never call the markRead JavaScript function on those pages.

Many thanks for your time and help.

OK using

$(".fb-recommendations-bar").data("href", href);

instead of

$(".fb-recommendations-bar").attr("data-href", href);

and

FB.XFBML.parse();

or

FB.XFBML.parse(document.getElementById('.fb-recommendations-bar'));

instead of

FB.XFBML.RecommendationsBar.markRead(href);

works!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM