I use a coffee script in my rails project, but the problem is that it only works when I load (refresh) a page, and when the page is displayed, it should also work on changing the appearance of the page.
here is the script i use:
facebook.js.coffee
jQuery -> $('body').prepend('<div id="fb-root"></div>') $.ajax url: "#{window.location.protocol}//connect.facebook.net/en_US/all.js" dataType: 'script' cache: true window.fbAsyncInit = -> FB.init(appId: env["app_id"], cookie: true) $('#sign_in').click (e) -> e.preventDefault() FB.login (response) -> window.location = '/auth/facebook/callback' if response.authResponse $('#sign_out').click (e) -> FB.getLoginStatus (response) -> FB.logout() if response.authResponse true
javascript jquery ruby-on-rails coffeescript
Amrinder singh
source share