2013-02-25 21 views
0

我的保存按钮有问题。当为我的按钮应用指定的JavaScript时,它不保存信息。但是,如果我删除JavaScript按钮的作品,并保存好信息。保存按钮因为javascript而不能保存

(function ($) { 

Views.Accounts = { 
    AddSaveBtnEvents: function() { 
     $(".savebtn").attr('disabled', 'disabled'); 

     $("#Username,#ProfileName").keyup(function(event) { 
      $(event.target).siblings('.savebtn').removeAttr('disabled', true); 
     }); 

      $(".savebtn").click(function() { 
      $(this).attr('disabled', 'disabled'); 
     }); 
    } 
}; 

$.views.Accounts.AddSaveBtnEvents(); 

})(jQuery); 
+0

我看到你的脚本用来禁用和重新启用按钮。是不是应该禁用按钮的问题? – 2013-02-25 16:38:09

+1

也许是由于语法错误。 – 2013-02-25 16:40:16

+0

@AaronKurtzhals保存按钮将被禁用,直到做出更改,然后按钮被启用,然后一旦它被点击,它将再次禁用。但数据实际上并未保存。 – BB987 2013-02-25 16:42:13

回答

0

我固定我自己的问题做了一些研究之后 - 我真的在按钮和类型来传递:

(function ($) { 

Views.Accounts = { 
    AddSaveBtnEvents: function() { 
     $('button[type=submit]').attr('disabled', 'disabled'); 

     $('#Username,#ProfileName').keyup(function(event) { 
      $(event.target).siblings('button[type=submit]').removeAttr('disabled'); 
     }); 

     $('button[type=submit').click(function() { 
      $(this).attr('disabled', 'disabled'); 
     }); 
    } 
}; 

$.views.Accounts.AddSaveBtnEvents(); 
})(jQuery); 
+0

所以你的保存按钮不*有'savebtn'类吗? – 2013-02-25 17:18:07

+0

它确实是一个奇怪的部分,但现在它正在改变之后。 – BB987 2013-02-25 17:24:14

+1

你应该使用'.prop('disabled',true);'不要认为http://jquery.com/upgrade-guide/1.9/#attr-versus-prop-当然是'.removeProp()'http ://api.jquery.com/removeProp/ – 2013-02-25 20:28:14