views:

407

answers:

2

Hey.... I followed the tips given on

Loading Facebook fb:profile via ajax

In my app, I am basically loading more comments posted by the user via Jquery and along with each comment showing the user's picture using the fb:profile-pic tag

This is a sample of how I'm building the string via Jquery

$(document).ready(function() 
{
  $(".more_comments").live('click',function() 
  {
    $.getJSON("/store/more-swipes",function(data) 
    {
      newcomment += "<fb:profile-pic uid='"+data.fb_userid+"'/>";
      newcomment += ""+data.user_name+": ";
      newcomment += ""+data.user_comment+": ";
     $("#morecomments").append(newcomment);
    });
return false;
  });
});

So the profile-pic was not being displayed - After reading the above link, I added

if ( FB.XFBML.Host.parseDomTree )
  setTimeout( FB.XFBML.Host.parseDomTree, 0 );

The weird thing now is - its working in Chrome and Firefox but not in IE Cant figure out why. Any help will be appreciated. Thanks

A: 

Try putting your code in the load event:

$(window).load(function(){
  // your code here...
});
Sarfraz
sarfraz thhanks for your post - my code is part of the $(".more_comments").live('click',function() { method which is called when the user clicks on the "more comments" link - I will edit the question to reflect that - So how would I add the code to the $(window).load function and why is that necessary
Gublooo
@Gublooo: The `load` event fires when all page DOM tree has been parsed and all external resources have loaded into the page. You should place your code inside that replacing my comment and then see if it works.
Sarfraz
@sarfraz - thanks - right now all my code is placed in $(document).ready(function() { - should i replace this method with the window.load method
Gublooo
@Gublooo: yes you can try that if it works after that.
Sarfraz
@sarfraz - I tried replacing the $(document).ready(function() with $(window).load(function(){ - it still doesn't work in IE - it works fine in other browsers - Thanks
Gublooo
A: 

Hey I'm not sure of the reason why - but making this change - the code started working in IE

From

newcomment += "<fb:profile-pic uid='12345'/>";

To

newcomment += "<fb:profile-pic uid='12345'></fb:profile-pic";

Hope it helps someone else - I wasted a lot of time debugging this one. Thanks

Gublooo