Friday, April 13, 2012

Rails 3 Facebook Ajax picture

My rails 3 website shows a list of friends, and you can click on "next" to see the 10 next friends.
I'm using this :

    

Problem : I can load dynamically and see my next friends but not their  facebook profile pictures. Why?

Solution : In fact, you just need to "refresh" (re-parse) the element.
Do not use FBML because it will be deprecated soon.
Instead, use FB.XFBML.parse();

For example, in my action (who has been called by using :remote => true), it returns a ".js.erb" file.
In this .js.erb file, I append my friends, and at the end I just do FB.XFBML.parse(XX), where XX is the name of the section that I want to "refresh"/"re-parse".

and that's it !

No comments: