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