0.0
No commit activity in last 3 years
No release in over 3 years
Facebook JavaScript SDK unobtrusive loader for jQuery and Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

jquery-facebox

An asynchronous and unobtrusive Facebook JavaScript SDK loader for jQuery and Rails.

Installation

Add this line to your application's Gemfile:

gem 'jquery-facebook'

And then execute:

$ bundle

Or install it yourself as:

$ gem install jquery-facebook

Usage

Include in your app/assets/javascripts/application.js:

//= require jquery.facebook

jQuery(function ($) {
  $.facebookInit();
});

It reads appId from fb:app_id meta tag by default:

<meta property="fb:app_id" content="...">

Options passed to facebookInit call will be passed to FB.init:

// defaults to:
// {
//   appId: '...', // appId from meta tag
//   status: true,
//   cookie: true,
//   xfbml: true
// }
$.facebookInit();

// to disable XFBML and logging
$.facebookInit({xfbml: false, logging: false});

// to override appId
$.facebookInit({appId: '...'});

After facebook initialization is complete facebook:init event is being triggered.

$(document).live('facebook:init', function () {
  alert('Done!');
});

Another way is to pass callback to the $.facebookLoaded function which will set the facebook:init event handler if facebook isn't loaded yet and fire the callback right away if it it.

$.facebookLoaded(function () {
  alert('Done!');
});

Changelog

v1.0.0

The default JS SDK version is 2.3 now.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request