title: Use Kaminari Pagination within a Bootstrap Modal
body: <p>I am having some difficulties getting the Kaminari gem to work with my Bootstrap modal.  I know that it needs to work primarily with Ajax, but I'm not quite sure what to do on this one.</p>
  
  <p>Specifically, I have over 800 images that are supposed to load in the Modal.  But, right now, all those images are loading at once, causing a long loading time.</p>
  
  <p>Here's what I currently have:</p>
  
  <p><strong><em>new.html.erb</em></strong></p>
  
  <pre><code>  # basic html items
   &lt;%= render "image_modal" %&gt;
  </code></pre>
  
  <p><strong><em>_image_modal.html.erb</em></strong></p>
  
  <pre><code> &lt;div class="modal fade" id="choosePicture" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&gt;
    &lt;div class="modal-dialog"&gt;
     &lt;div class="modal-content"&gt;
       &lt;div class="modal-header"&gt;
         &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&amp;times;&lt;/button&gt;
         &lt;h4 class="modal-title"&gt;Choose Your Image&lt;/h4&gt;
       &lt;/div&gt;
       &lt;div class="modal-body"&gt;
        &lt;div class="row"&gt;
            &lt;% @images_by_filename.each do |image|  %&gt;
            &lt;div class=" col-xs-3"&gt;
                &lt;div class="thumbnail"&gt;
                  &lt;%= image_tag image.picture(:square), :title =&gt; image.name, :id =&gt; image.id, :image_url =&gt; image.picture(:thumb), :class =&gt; "list_thumb image-select style_image" %&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;% end  %&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="modal-footer"&gt;
     &lt;div class="form-group"&gt;
      &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Cancel&lt;/button&gt;
     &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;&lt;!-- /.modal-content --&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p><strong><em>images_controller.rb</em></strong></p>
  
  <pre><code>class ImagesController &lt; ApplicationController
    def new
      @template = Template.new
      @groups = Group.all
      @images = @images_by_filename
      @template.template_assignments.build
    end
   end
  </code></pre>
  
  <p>How could I incorporate Kaminari to work within this modal, separately?  When I try to implement the pagination, it ends up refreshing the entire page, as opposed to just within the modal.</p>
  
  <p>Any help on this would be great! </p>