1

ここでChris Healdの答えを使用しました:「http://stackoverflow.com/questions/4491433/turn-omniauth-facebook-login-into-a-popup」で、完全に機能しました。

1 つの問題はリダイレクトにあります。Facebook ログインに Devise と Oauth を使用しています。ログイン後にポップアップを閉じ、サインイン/サインアップ後にユーザーが適切なページにリダイレクトされるようにします。

何らかの理由で、現在、適切なパスがポップアップ ウィンドウに読み込まれ、ポップアップ ウィンドウが閉じません。私は非常に基本的な何かが欠けていると思います。何か案は?私は全くのJS初心者です!!

ポップアップの JS:

function popupCenter(url, width, height, name) {
    var left = (screen.width/2)-(width/2);
    var top = (screen.height/2)-(height/2);
    return window.open(url, name, "menubar=no,toolbar=no,status=no,width="+width+",height="+height+",toolbar=no,left="+left+",top="+top);
  }

  $("a.popup").click(function(e) {
    popupCenter($(this).attr("href"), $(this).attr("data-width"), $(this).attr("data-height"), "authPopup");
    e.stopPropagation(); return false;
});

リダイレクト用の JS:

if(window.opener) {
    window.opener.location = <%= after_sign_in_path %>;
    window.close()
  }
4

1 に答える 1

0

after_sign_in_path が引用符で囲まれていますか? 代わりにこれを試してみてください:

window.opener.location = "<%= after_sign_in_path %>"

その行が実行される前にjavascriptエラーがあるため、ウィンドウが閉じていないと思われます。

于 2012-11-07T12:57:24.317 に答える