Can I do escape_javascript with JSON respond?
I run Rails 4.2.1 and testing OAuth with Facebook. I've made link_to with remote true and ajax request with Facebook SDK.
window.fbAsyncInit = ->
FB.init
appId: 'AppID'
status: true
cookie: true
xfbml: true
return
((d) ->
js = undefined
id = 'facebook-jssdk'
if d.getElementById(id)
return
js = d.createElement('script')
js.id = id
js.async = true
js.src = '//connect.facebook.net/en_US/all.js'
d.getElementsByTagName('head')[0].appendChild js
return
) document
$ ->
$('#facebook, #vkontakte').click (e) ->
e.preventDefault()
FB.login ((response) ->
if response.authResponse
$('.modal').modal('hide')
# $('#results').html 'Connected! Hitting OmniAuth callback (GET users/auth/facebook/callback)...'
# since we have cookies enabled, this request will allow omniauth to parse
# out the auth code from the signed request in the fbsr_XXX cookie
$.getJSON '/profile/auth/facebook/callback', (json) ->
# $('#results').html JSON.stringify(json)
# Do some other stuff here (call more json, load in more elements, etc)
return
return
), scope: 'email'
# These are the permissions you are requesting
return
$('#connect .signout').click (e) ->
e.preventDefault()
$.getJSON '/auth/facebook/signout', (json) ->
$('#results').html JSON.stringify(json)
return
return
return
Everything works fine, I got my user signed in with his account, however I need to make some front-end updates (i.e. re-render few partials etc..) I do like remote true and javascript_escape concept so I'd be happy to use same on JSON, however can't find any examples..