Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7802745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:20:49+00:00 2026-06-02T01:20:49+00:00

I have a JS photo gallery that loads individual images from an API into

  • 0

I have a JS photo gallery that loads individual images from an API into the page when users click a thumbnail. I’d like people to be able to add Facebook comments on each image. So I’ve got my Facebook comments element in the page that contains the gallery.

<div class="fb-comments" data-href="" data-num-posts="10" data-width="480"></div>

On loading the page and first populating the gallery I set the data-href attribute of the comments element to the URL for the first image (for example http://site.com/gallery/1027/1). Then if the user clicks on a thumbnail I reset that attribute to the URL for the selected image.

fbComments.attr('data-href', data.link + index);
FB.XFBML.parse();

The FB.XFBML.parse(); is what I’ve read you’re supposed to do to get Facebook to refresh the comments. I’ve added a comment to one image and tried clicking on the thumbnail for an image without a comment. But my comment for the first image is still there. Can anyone suggest why?

I’ve tried logging out the FB object in my JS file, and it logs OK, so it is available at the point I call it. I’ve checked that the click event in my JS is indeed changing the data-href attribute to the right value. And when I hardcode a different data-href in the fb-comments element the comments render as expected.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:20:52+00:00Added an answer on June 2, 2026 at 1:20 am

    I suggest that you completely remove the previous comments box from the dom, then insert a new html with the right data-href and then call the FB.XFBML.parse method.

    Another thing is that you should specify where to parse, like so:

    FB.XFBML.parse(document.getElementById("container-id"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP photo gallery that reads the GPS coordinates from images. I'd
I have photo gallery code that does image re-sizing and thumbnail creation. I use
I have a photo gallery I would like that every time a user does
I have an app that behaves somewhat like a photo gallery. They choose an
So I have an app that behaves like a photo gallery and I'm implementing
I have a photo gallery page that shows a series of thumbnails that are
I have a photo gallery that uses images cut off at an odd angle
I have a Bitmap that I chose from gallery that is getting edited like
I have a photo gallery web page where a single <img src="XXX" /> element's
I have a website with photo gallery and I'd like to upload each photo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.