Problems with multiple ajax forms on the same page

0

I'm having a strange problem when I put multiple forms on a single page (in the index case) all have the remote: true parameter created from a loop in my records. The problem is that only the first form works with ajax, the second sends a normal requeste and is directed to the show.

Below my index that is where my forms are generated:

  <% @mensagens.each do |mensagem| %>
  <%= form_for(mensagem, remote: true,:authenticity_token => true) do |f| %>
  <div class="row">    
    <div class="col-md-9">
      <div class="widget">        
        <!-- BLOCK -->

          <div class="row innerAll half border-bottom">
            <div class="col-sm-12">
              <div class="media-body">
                <div class="innerAll half">
                  <div class='col-md-10'><%= f.number_field :avaliacao %></div>
                  <div class='col-md-2'><%= mensagem.slug %></div>
                </div>                    
              </div>
            </div>
          </div>

          <div class="row innerAll half border-bottom">
            <div class="col-sm-12">
              <div class="media-body">
                <div class="innerAll half">
                  <%= f.text_area :texto, :class=>"col-md-12 form-control", :placeholder=>"Mensagem" %>
                </div>                    
              </div>
            </div>
          </div>

          <div class="row innerAll half border-bottom">
            <div class="col-sm-12">
              <div class="media-body">
                <div class="innerAll half ">
                  <div class="col-md-2"><%= f.check_box :aprovado %></div>
                  <div class="col-md-2"><%= f.check_box :status %></div>
                  <div class="col-md-6 btn"><%= f.text_field :autor,:class=>"form-control", :placeholder=>"Autor" %></div> 
                  <div class="col-md-2"><%= f.submit "Salvar", :class=>"btn btn-success" %></div>
                </div>                    
              </div>
            </div>
          </div>


          <div class="row innerAll half border-bottom">
            <div class="col-sm-12">
              <div class='notyfy_wrapper mensagem_<%= mensagem.id %>'>
                <div class="notyfy_message">
                  <span class="notyfy_text">
                    <div id="alerta"></div>
                  </span>
                </div>
              </div>
            </div>
          </div>          

      </div>
      <!-- BLOCK -->
    </div>



  </div>

  <% end %>
  <% end %>

I put the page in the air so you can take a look: link

    
asked by anonymous 06.03.2014 / 12:06

1 answer

1

By analyzing your page I realize that the error is not exactly in remote but in your form because one is contained within the other.

For example:

<form>
   <form>

   </form>
</form>
    
06.03.2014 / 12:41