我昨晚才注意到它,从那以后就一直想弄清楚它为什么会这样。我有一个响应 js 的 ajax/remote 表单。当我单击带有按钮标签的任何元素时,我的表单将提交它。知道这里发生了什么吗?
一些代码:(我有一些按钮在使用jquery悬停在某些单词上时会弹出,但在添加它们之前就存在问题)
<%= semantic_form_for(@post, :html => {:multipart => true, class: "form-vertical"}, :remote => true) do |f| %>
<%= f.text_field :name %>
<%= f.text_area :description %> <!-- a li list of 4 horizontal buttons popup when hover -->
<button class="btn-save"> <!-- found out I didn't even need the input submit button -->
<span>Save</span>
</button>
<% end %>
#posts controller
# GET /posts/1/edit
def edit
@post = Post.find(params[:id])
end
# PUT /posts/1
# PUT /posts/1.json
def update
@post = Post.find(params[:id])
respond_to do |format|
if @post.update_attributes(post_params_update)
flash.now[:notice] = "successfully updated!"
format.html { redirect_to edit_post_path(@post), notice: 'successfully updated!' }
format.json { render json: edit_post_path(@post), status: :created, location: @post }
format.js
else
format.html { render action: "edit" }
format.json { render json: @post.errors, status: :unprocessable_entity }
format.js
end
end
end
我什至尝试删除所有其余的 js 文件.. 还是一样