【发布时间】:2015-08-12 14:21:53
【问题描述】:
在表单外部的视图中,我有一个“更新”按钮。当我单击按钮时没有任何反应。请帮忙。非常感谢。
(haml)
%button#update_button(type="submit) Update
The call for the form:
= form_for @employee, id: 'employee-update-form' do |f|
...
And the JS intended to submit the form:
:javascript
$('#update_button').click(function() {
$('#employee-update-form').submit(function() {
$.ajax({
type: "PATCH",
url: '#{employee_path(@employee)}'
data: $('#employee-update-form').serialize(),
dataType: "JSON"
}).success(function(json) {
});
return false; // prevents normal behavior
});
【问题讨论】:
标签: jquery ruby-on-rails haml