I have a problem with my code that is meant to create the Facebook Connect login popup. In the code below, if I include the click event in my document ready then it triggers the creation of 2 popups, but if I leave it outside of the document ready then it fails to create any popup. Can anybody advise?
<script type="text/javascript">
$(document).ready(function () {
window.FB.init({ appId: 'xxx', status: true, cookie: true, xfbml: true });
});
$('#fbLogin').click(function () {
window.FB.login(function (response) {
if (response.status == 'connected') {
window.location.href = 'redirecturl';
}
}, { perms: 'email' });
});
</script>
<fb:login-button autologoutlink="false" perms="email" id="fbLogin">
</fb:login-button>
fb:login-buttonwill rise login dialog.#fbloginwill open second dialogYou need to choose one of
fb:login-buttonorFB.loginnot both.If you need page redirected once user is logged in just remove the
FB.logincall and subscribe (FB.Event.subscribe) toauth.statusChangeevent to check login status.