【发布时间】:2011-06-15 13:59:39
【问题描述】:
我正在开发一个 Ruby On Rails 2.3.8 应用程序,我想知道当用户在文本区域中按下 ENTER 键时如何提交 remote_form_for 表单。
表格代码如下:
<% remote_form_for :post, PostComment.new, :url => save_outside_comment_path(post_id), :html => { :method => :put} do |f| %>
<%= f.text_area :comment, :rows => 1, :id => "txtOutsideComment_#{post_id}", :class => "new-reply-text" %>
<% end %>
这是执行提交但不是 AJAX 的 jQuery 函数:
jQuery('.new-reply-text').keypress(function(e) {
if (e.keyCode == 13 && !e.shiftKey) {
e.preventDefault();
this.form.submit();
}
});
我已经从我的控制器进行了页面更新,我不想从这个 jQuery 函数中指定任何语法,如 success:。我只是希望它使用 AJAX 提交remote_form_for。
【问题讨论】:
标签: jquery ruby-on-rails ajax