WordPress.org

Ready to get started?Download WordPress

Forums

Facebook
[resolved] FB Comments AJAX (7 posts)

  1. neesley
    Member
    Posted 1 year ago #

    What script would I run in an AJAX page call to re-parse the Facebook comments? The don't appear when loading a page via AJAX...

    http://wordpress.org/extend/plugins/facebook/

  2. Niall Kennedy
    Member
    Plugin Author

    Posted 1 year ago #

    Are you looking for something such as the Facebook JavaScript SDK's FB.XFBML.parse() method?

  3. neesley
    Member
    Posted 1 year ago #

    Yup. Just not quite sure where to integrate it. I imagine it must be in an AJAX call in my theme, but I thought there may be an offhand chance I can include it in the FB plugin files somewhere.

  4. Niall Kennedy
    Member
    Plugin Author

    Posted 1 year ago #

    The plugin outputs the HTML elements with data-* attributes for interpretation by the Facebook JavaScript SDK. The Facebook JavaScript SDK is then enqueued, loaded asynchronously, and creates the fbAsyncInit JavaScript function referenced by the Facebook JavaScript SDK after it has loaded. Inside the fbAsyncInit function called after the Facebook JavaScript SDK loads is a call to FB.init with xfbml=true, which triggers the FB.XFBML.parse() function against body.

    If the initial pageload passes through WordPress and loads the JavaScript SDK and its init function then you should trigger FB.XFBML.parse() against the root element of your new fragment after it is inserted into the page.

  5. neesley
    Member
    Posted 1 year ago #

    That's what I was thinking, but it's my understanding that an AJAX call will strip out any Javascript in the called fragment. So the parsing command would need to be included in the fragment call.

    Am I on the right track?

  6. Niall Kennedy
    Member
    Plugin Author

    Posted 1 year ago #

    Depends on your theme or method of loading. You might include a success function, allow plugins to add their own JavaScript calls through an action or something similar.

  7. neesley
    Member
    Posted 1 year ago #

    I got this working.

    Unfortunately, during the last two updates, something else went wrong.

    Now, the very first comment will not load.

    I.e. when a user makes the first comment--nothing shows up. When the page reloads, the comment shows up--and here's the tricky part--subsequent comments do appear right away. And deletions also go away immediately.

    This happens when my page is loaded via an AJAX call and when it's loaded without an AJAX call.

    Any help? Thanks in advance.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags