我昨天晚上才注意到它,从那以后一直在努力弄清楚它为什么这样做。我有一个响应js的ajax /远程表单。当我单击带有环绕的按钮标签的任何元素时,我的表单就会提交它。对这里发生的事情有任何想法吗?
一些代码:(当我使用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文件。
如果您不希望在单击按钮时提交表单,则需要将type =“ button添加到按钮标记中。
<button type="button">...<button>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句