【问题标题】:jQuery: re-bind works after ajaxForm submit returns HTML, but not subsequent submit...why, is one rebind the limit?jQuery:在 ajaxForm 提交返回 HTML 后重新绑定有效,但后续提交无效...为什么,重新绑定是否有限制?
【发布时间】:2010-11-02 20:52:35
【问题描述】:

您好,我有一个带有按钮和链接 jQuery 事件的表单。我正在使用 ajaxForm 提交表单,它会在成功时返回另一个表单。第二种形式具有相同的按钮和链接 jQuery 事件,我使用在 document.ready() 函数开头调用的 init 函数重新绑定这些事件。重新绑定工作正常。当我使用 ajaxForm 提交第二个表单时,会返回带有相同按钮和链接事件的第三个表单。尽管使用第二个 init 函数,但按钮和链接事件不会重新绑定,这就是问题所在。这是对 jQuery 的限制 - 重新绑定两次吗?任何想法都非常感谢。

代码:

//init functions
jQuery(document).ready(function() {

   initBinding();
   initBindingTwo();

  //button 

jQuery('#next_button').button({
  icons: { secondary: 'ui-icon-carat-1-e' }
);

// pass options to ajaxForm for first form sumit of new program

jQuery('#new_program_form').ajaxForm(options);

//this one works after first form submit
function initBinding() {
     jQuery('#next_button').button({
  icons: { secondary: 'ui-icon-carat-1-e' }
 });


 //this one does not work after second form submit
 function initBindingTwo() {
     jQuery('#next_button').button({
  icons: { secondary: 'ui-icon-carat-1-e' }
 });

});

【问题讨论】:

    标签: jquery bind ajaxform


    【解决方案1】:

    我最终放弃了上面的方法,坚持了两次ajax调用,只提交了两次表单,解决了问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-17
      • 2019-06-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多