webtechnick / CakePHP-Facebook-Plugin

CakePHP Facebook Plugin
http://facebook.webtechnick.com
445 stars 138 forks source link

Cannot reinitialze Facebook->init() after Ajax calls #120

Closed starchildno1 closed 11 years ago

starchildno1 commented 11 years ago

If any of the Facebook->helpers that requires init(), are in elements updated by ajax then those helpers would break. I tried using the picture helper in a comments app but after an ajax update the picture helper is gone. It also happens on elements that contained like and share as well. Normally in my View-js directory I would normally just call mySpecialScript.setup() and the script would be reinitialized. But i tried this-Js-Object(this-Facebook->init()). The thing is it only loads partially- div id="fb-root" with only script async="" src="http://connect.facebook.net/en_US/all.js" included.

Is there a way to reinitialize Facebook-init() after ajax calls?

starchildno1 commented 11 years ago

As far as the picture goes, I just make a static call to FB.api get the picture's url of the facebook user and append it to FB.Me Session in the afterFacebookLogin

Although I can now access the users profile pic after ajax calls, that still does not help the Facebook Helper methods that depend on Facebook-init()

public function afterFacebookLogin(){ App::uses('FB', 'Facebook.Lib'); $Me = FB::api('/me'); $FBpicture = FB::api('/me/?fields=picture'); $picture['picture'] = $FBpicture['picture']['data']['url']; $this->Session->write('FB.Me', array_merge($Me, $picture)); }

starchildno1 commented 11 years ago

Well it's not the Helper, It's just ignorance. We use FB.XFBML.parse(); to re-render the helpers when using Ajax.