I have the following code to dynamically load an XFBML fragment into a Facebook IFRAME application.
HTML:
<div id="fragment" style="display:none">
<fb:serverfbml id="fragmentfbml">
</fb:serverfbml>
JQuery Code:
<script type="text/javascript">
function loadFragment()
{
jQuery.ajax(
{
url: "xfbml_fragment.php",
type: "POST",
dataType: "html",
cache: "false",
success: function (data)
{
jQuery("#fragmentfbml").html(data);
FB.XFBML.parse();
jQuery("#fragment").css("display","block");
}
});
}
</script>
The jQuery AJAX call works every time, but the FB.XFBML.parse () call only works once. I added a callback to FB.XFBML.parse () using console.log () (see below) and confirmed that it only executed the first time it called.
FB.XFBML.parse(
document.getElementbyId("fragment"),
function( { console.log("parse called"); } )
);
Is this the famous behavior of FB.XFBML.parse () (of course, this is not mentioned in the FB Javascript SDK docs ) or am I just doing something wrong here?
source
share