2010-05-11 143 views
0

我想弄清楚爲什麼這是使用jQuery 1.4.2而不是1.3.2時的問題。內容重新加載ajax後重新綁定ajaxForm(jQuery 1.4.2)

這是我的函數:

function prepare_logo_upload() { 
    $("#logo-upload-form").ajaxForm({ 
     //alert(responseText);          
     success: function(responseText) { 
      //alert(responseText);           
      $('#profile .wrapper').html(responseText); 
      prepare_logo_upload(); 
     } 
    }); 
} 

每隔現場活動的作品,但因爲給ajaxForm是一個插件不能使用.live()方法。 我注意到這也適用於其他類型的綁定(點擊)使用舊的形式(回調後重新綁定)

你能告訴我,如果這是解決這個問題的方法嗎?

這是一個類似的問題,但由於我的新手聲望,不能在那裏發表評論或提問,所以我會在這裏問一個新問題。 - >jQuery: Bind ajaxForm to a form on a page loaded via .load()

謝謝!

編輯:「#profile .wrapper」包含窗體,所以我的問題是在它重新加載後重新綁定事件。

+1

'#profile'是否包含'#logo-upload-form'? – 2010-05-11 22:33:05

+0

是的,抱歉不提起來!它加載表單並替換它,所以我的問題是在重新加載後重新綁定它。 – Cristian 2010-05-12 08:47:03

回答

0

只是猜測,但是,這樣的事情?


$("#logo-upload-form").live("submit", function() { 
    return (function() { 
     jQuery(this).ajaxForm({ 
      //alert(responseText);          
      success: function(responseText) { 
       //alert(responseText);           
       $('#profile .wrapper').html(responseText); 
       // recursion 
       return arguments.callee(); 
      } 
     }); 
    }()); 
}); 

完全未經測試,順便說一句。

+0

這很有趣,它再次加載整個頁面.wrapper div 我認爲它不適用於僅在提交時附加ajaxForm,它需要在加載時附加。 感謝您的嘗試! – Cristian 2010-05-12 08:56:22