2010-05-11 101 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