1

昨夜気付いたばかりで、それ以来、なぜこれをしているのかを理解しようとしています。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ファイルをすべて削除しようとしました..それでも同じです

4

1 に答える 1