我试图#url_form
在将 URL 粘贴到#video_url
. 该类.loading
已正确添加,但仍未提交表单。这是代码:
$(document).ready(function(){
$("#url_form").live("paste", "#video_url", function(){
$("#video_url").addClass("loading");
$("#url_form").submit();
});
});
和 HTML:
<form accept-charset="UTF-8" action="/posts/get_video" data-remote="true" id="url_form" method="post">
<input autofocus="autofocus" class="post-modal-url loading" id="video_url" name="video_url" placeholder="Paste a URL here" required="required" type="url">
</form>
Rails form_tag:
<%= form_tag get_video_posts_path, :remote => true, :id => "url_form" do -%>
<%= url_field_tag 'video_url', params[:video_url], :placeholder => "Paste a URL here", :required => true, :autofocus => true, :class => "post-modal-url" -%>
<% end -%>