0
我有一个表单。ajax:清除输入前
<%= simple_form_for(@something, :remote => true) do |f| %>
<%= f.input :name, :label => false, :placeholder => "Add new something" %>
<% end %>
它没有按钮,提交是通过点击返回来实现的。
有一些javascript可以对提交表单起作用。
$('form.new_something')
.on("ajax:before", function(){
$text_box = $('input:text', this);
$text_box.prop('disabled', true);
$text_box.val('Loading...');
})
这导致我的我的新东西模型的“名”属性被设置为“空”而不是文本框的值。
我认为这是因为我使用了“ajax:before”,这是在发布之前触发的。
有关我该怎么做的任何建议?
为什么设置'$ text_box.prop('disabled',true);'当使用'.prop()'而不是'.attr()'时[disabled](http://www.w3schools.com /tags/att_input_disabled.asp)是[属性](http://api.jquery.com/attr/),而不是[property](http://api.jquery.com/prop/)? – Vishal
使用道具的jQuery建议 - http://api.jquery.com/prop/#prop2 – Finnnn
对呀!我猜是的。我希望这相当于'.attr('disabled','disabled')',没有什么区别。 – Vishal