我正在尝试将网址粘贴到#url_form
时提交#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 -%>
答案 0 :(得分:3)
变化
$("url_form").submit();
到
$("#url_form").submit();