title: Ruby on rails - Load more button with kaminari and search form. Jquery problems
body: <p>I have an ajax search form and ajax pagination using kaminari. I would like to change this into a 'load more' button but I'm having trouble with the jquery. </p>
  
  <p>For the form and normal pagination I was using this in my index.js.erb ;</p>
  
  <pre><code>$('.gig-search-list').html("&lt;%= j render(partial: 'gigs') %&gt;");
  </code></pre>
  
  <p>This replaces all the current results with the new results from the search form, or the next page being selected with the kaminari gem.</p>
  
  <hr>
  
  <p>I would like to have the 'load more' button add the results to the bottom of the page, but still have the search form behave as before.</p>
  
  <p>With the example below, the 'load more' button works as desired, but the search form doesn't work at all.</p>
  
  <pre><code> $('.gig-search-list').append("&lt;%= j render(partial: 'gigs') %&gt;");
  </code></pre>
  
  <hr>
  
  <p>I then tried separating them....</p>
  
  <pre><code>$("#gig_search_form").submit(function() {
      $('.gig-search-list').html("&lt;%= j render(partial: 'gigs') %&gt;")
              $('#map').html('&lt;%= j render("map") %&gt;');
  });
  
  $(".pagination").click(function(){
          $(".gig-search-list").append("&lt;%= j render(partial: 'gigs') %&gt;");
          $('#map').html('&lt;%= j render("map") %&gt;');
  });
  </code></pre>
  
  <p>This kind of works...a bit.... although I have to click twice, or submit the form twice to get the functions to fire. The pagination part doesn't take into account the search parameters and the search is all over the place too.</p>
  
  <hr>
  
  <p>How can I combine the two functions? Use .html for the search form and .append for the pagination?</p>