2011-12-14 6 views
0

ページをリロードした後、このコードは正常に動作します - javascriptが機能し、ポップアップが開きます。しかし、AJAXを使用してajaxUpdatableの内容を変更しても、動作しません。私のeauth機能のために、ここで何か "再結合"するか、または.live()を作る方法はありますか?AJAXの後でJavaScriptを動作させるには?

$("a.google").eauth({"popup":{"width":880,"height":520},"id":"google"}); 

ここに完全ページがあります。

<div class="ajaxUpdatable"> 
    <a class="direct auth-link google" href="/coverication/? 
r=site/login&amp;service=google">Google</a> 
<a class="direct auth-link yandex" href="/coverication/?r=site/login&amp;service=yandex">Яндекс 
</div> 

<script type="text/javascript"> 
jQuery(function($) { 
    var popup; 

    $.fn.eauth = function(options) { 
     options = $.extend({ 
      id: '', 
      popup: { 
       width: 450, 
       height: 380 
      } 
     }, options); 

     return this.each(function() { 
      var el = $(this); 
      el.live('click', function() { 
         if (popup !== undefined) 
          popup.close(); 

         var url = this.href + (this.href.indexOf('?') >= 0 ? '&' : '?') + 'js'; 
         /*var remember = $(this).parents('.auth-services').parent().find('.auth-services-rememberme'); 
         if (remember.size() > 0 && remember.find('input').is(':checked')) 
          url += '&remember';*/ 

         var centerWidth = ($(window).width() - options.popup.width)/2; 
         var centerHeight = ($(window).height() - options.popup.height)/2; 

         popup = window.open(url, "yii_eauth_popup", "width=" + options.popup.width + ",height=" + options.popup.height + ",left=" + centerWidth + ",top=" + centerHeight + ",resizable=yes,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=yes"); 
         popup.focus(); 

         return false; 
        }); 
     }); 
    }; 
}); 

$("a.google").eauth({"popup":{"width":880,"height":520},"id":"google"}); 
$("a.yandex").eauth({"popup":{"width":900,"height":550},"id":"yandex"}); 
</script> 
+1

を試してみてください。 –

+0

うーん..その後、誰がeauth機能を呼び出す必要がありますか? –

+0

Ajax呼び出しによってコンテンツが変更されたときに実行されるコールバック関数。 –

答えて

0

私はちょうど関数に以下の2行を入れて、内容が変更された時はいつでもそれを呼ぶだろう。この

$("a.google").live("eauth", function({ 
    "popup": { "width": 880, "height": 520 }, 
    "id": "google" 
}); 
+1

'eauth'はトリガーされるイベントですか?既に –

+0

が試行されました。ライブの最初のパラメータはイベントでなければなりません。しかし、私は機能です。私の元の投稿でlive()と言っているのは、更新されたajaxコンテンツのために "reload"するためのlive()のようなものです。 –

関連する問題