mandar.gokhale
mandar.gokhale

Reputation: 1875

Error While poping up facebook application request dialog in rail application

hi I am using following code to pop up Facebook application request dialog in my rails application.

$('#app_request').live("click", function () {
  FB.ui({
        method: 'apprequests',
        message: 'You should learn more about this awesome game.',
        data: 'tracking information for the user'
        });
    });

but I am getting the error as FB is not defined what should I do to correct it. I am new to rail development & FB applications. please guide me. Thank You.

Upvotes: 2

Views: 306

Answers (1)

jBit
jBit

Reputation: 2981

You need to load and initialise the Facebook JavaScript SDK - for example:

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({appId: 'your app id', status: true, cookie: true, xfbml: true});
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());
</script>

Upvotes: 1

Related Questions