I try to install FOSFacebook, I have follow all the steps, but i got this error in js console:
Uncaught ReferenceError: onFbInit is not defined
I have include this lignes in my base.html.twig:
<!-- FaceBook Init -->
{{ facebook_initialize({'xfbml': true, 'fbAsyncInit': 'onFbInit();'}) }}
{{ facebook_login_button({'autologoutlink': true}) }}
<script>
$(document).ready(function() {
function goLogIn(){
window.location = "{{ path('_security_check') }}";
}
function onFbInit() {
if (typeof(FB) != 'undefined' && FB != null ) {
FB.Event.subscribe('auth.statusChange', function(response) {
if (response.session || response.authResponse) {
setTimeout(goLogIn, 500);
} else {
window.location = "{{ path('_security_logout') }}";
}
});
}
}
});
</script>
Someone can help me? Thx
Don´t define those functions within your $(document).ready(function() call. Use:
<script>
function goLogIn(){
window.location = "{{ path('_security_check') }}";
}
function onFbInit() {
if (typeof(FB) != 'undefined' && FB != null ) {
FB.Event.subscribe('auth.statusChange', function(response) {
if (response.session || response.authResponse) {
setTimeout(goLogIn, 500);
} else {
window.location = "{{ path('_security_logout') }}";
}
});
}
}
</script>