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 8476965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:19:26+00:00 2026-06-10T18:19:26+00:00

I have a function that load a jquery ui accordion (differents accordions based on

  • 0
  1. I have a function that load a jquery ui accordion (differents accordions based on different id)
  2. When I click on the tab titled “Facebook Comments” I do:

    $("#myaccordion").bind('accordionchange', function(event, ui) {
        id = $("#myaccordion").data('id');
        switch (ui.newHeader.text()) {
            case "Facebook Comments":
                displayFb(id);
                break;
        }
    });
    
  3. The “displayFB” function is:

    function displayFb(id){
        $.get('/fbcomments/' + id, function(data) {
            $("#facecomm").append(data);
            });
        }
    

    Where http://www.myweb.com/fbcomments/id is:

    <div id="fb-root"></div>
    <script>(function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/es_ES/all.js#xfbml=1";
        fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));</script>
    <div class="fb-comments" data-href="<?php echo '/fbcomments/'.$id ?>" data-num-posts="10" data-width="220"></div>
    
  4. When I load the homepage, then choose an accordion, then open a Facebook Comments, it works perfect. If I reload the page and choose another accordion, work perfect again. The problem is when I choose another accordion or the same again without reload the whole page. The accordions loads very well, all the data on them (some tabs of images, text, videos, etc), but the facebook comments don’t appear.

  5. I tried:

    • loading the #fb-root and facebook comment <script> on the main layout….doesn’t work.
    • adding FB.XFBML.parse(); into displayFB function….doesn’t work
    • adding FB.XFBML.parse(); into a $(document).ready(function(){} …doesn’t work.
  6. Thank you for reading and try to help!!

UPDATE:

  1. I made this little demo…I can’t make it work…maybe jsfiddle is not the best place to insert Facebook Comments: My First Fiddle

  2. Maybe is important to say that I use cakephp on my site…

  3. Please remember that my code works perfect at first accordion call and displayFb function…then when I change to other accordion…it crash…

  4. Thank you again!!

UPDATE2:

  1. This is another question of a user….very similar to mine. Please see that his doesn’t use an accordion…but jquery in common….maybe somebody could understand better than me the answer…
  • 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-10T18:19:28+00:00Added an answer on June 10, 2026 at 6:19 pm

    Where http://www.myweb.com/fbcomments/id is:

    So you’re effectively adding the DIV element #fb-root and loading the JS SDK over and over again and place it inside your document … which is not a good idea.

    Try loading only the .fb-comments element via AJAX, and run FB.XFBML.parse on that new piece of content afterwards.

    Embed #fb-root and the JS SDK in your page from the beginning, and only once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this jquery function function example(file, targetwidget, callback){ $(targetwidget).load(file, {limit: 25}, function(){ $(#widget_accordion).accordion({fillSpace:
I have a page that dynamically loads content with the jQuery load() function, so
I have the following scenario jQuery('#content').fadeOut('slow',function(){ jQuery('#content').load(detail.php?product=+imgID+&category=+cat); jQuery('#content').fadeIn('fast'); }); My problem however is that
I have a data-upload function that load some data into several tables and processes
I have a large function that I wish to load only when it is
I have a deferred function that binds a mouseenter event: $(window).load(function(e) { var $container
I have a java script function that i have called on body load mousemove()
I have this class that have a function to load other classes and create
I have function Start() that is fired on ready. When I click on .ExampleClick
I currently have a JS function that allows me to load partial content from

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.