0

我试图#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 -%>
4

1 回答 1

3

改变

 $("url_form").submit();

$("#url_form").submit();
于 2012-11-08T01:46:30.967 回答