2016-12-07 1 views
0

이 비디오 http://railscasts.com/episodes/240-search-sort-paginate-with-ajax?autoplay=true을 따라 왔는데 다른 형식으로 레코드를 검색하려고하지만 작동하지 않습니다. 어떻게 해결할 수 있습니까? 저장할 레코드를 검색 할 양식을 만들려면 검색 양식을 넣어야합니다. 이것은 내 양식입니다 :다른 형식의 리모콘 form_tag

<%= form_for(@cliente, remote: true, html: {class: "form-horizontal cliente-validado"}) do |f| %> <!--ajax remote: true--> 
    <div class="modal fade" id="mynewcliente" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> 
    <div class="modal-dialog" role="document"> 
     <div class="modal-content"> 
     <div class="modal-header"> 
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> 
      <h4 class="modal-title" id="myModalLabel">Agregar cliente</h4> 
     </div> 
     <div class="modal-body"> 

      <%= f.label :IdCli, "Clave:", class: "control-label col-md-2" %> 
      <div class="col-md-7"> 
       <%= f.text_field :IdCli, class: "form-control cliente-idcli",autofocus: true, minlength: "1", required: "true" %> 
      </div> 

<!--the search form--> 
       <%= form_for("/busqueda_cp", method: 'get', remote: true, id:"cp_search") do |l| %> 
       <p> 
       <%= l.text_field :search, params[:search]%> 
       <%= submit_tag "Search", :name => nil%> 
       </p> 
       <%end%> 
       <div id="cp"><%= render 'cp' %></div> 

      <div class="form-group"> 
      <%= f.label :Status,"Activo:", class: "control-label col-xs-3 col-sm-6 col-md-1 " %> 
      <div class="col-md-1"> 
       <%= f.check_box :Status, checked: true %> 
      </div> 
      </div> 
     </div> 

     <div class="modal-footer"> 
      <button type="button" class="btn btn-default" data-dismiss="modal" id="mynewclienteclose">Close</button> 
      <%= submit_tag "Create", class: "btn btn-primary", data: { disable_with: 'Creando' }%> 
     </div> 
     </div> 
    </div> 
    </div> 
<%end%> 
</div> 
+0

설명 "작동하지 않습니다". 무슨 일이야? – Beartech

+0

@Beartech serarch 폼은 다른 폼 내부에 없으면 작동하지만 폼이나 다른 폼을 작성할 때 레코드를 찾지 않습니다. – LuisC

+1

아래의 대답에 따르면 폼 내의 폼은 표준이 아닙니다. 검색 필드를 양식 외부에 놓을 수 있지만 CSS를 사용하여 올바른 위치에 표시 할 수 있습니까? 검색 양식이 포함 된 양식에 정보를 추가해야하는 경우 AJAX가 양식을 수정하도록 반환함으로써이를 수행 할 수 있습니다. – Beartech

답변