0
votes

Dears, i have trouble with pagination links. I use rails 4.2 and will_paginate gem.

I have @students and one set of pagination links. I have search form, which gets data using ajax request. After this request i have new set of pagination links.

I need: - to draw new set of pagination links - make active link to first page

I have now: - old pagination links with old active page number

<div id='paginator'><%= will_paginate @students %></div>
<script>
   //some get function to get data
   drawTable(data);
   function drawTable(data) {
      for (var i = 0; i < data.length; i++) {
        drawRow(data[i]);
      }
      document.getElementById("paginator").innerHTML = "";
      $('#paginator').append($('<%= will_paginate @students %>'));
  }
</script>

As you see, i remove content of paginator div and draw it again. But i have the old link anyways.

Guys, what i'm doing wrong??? Where is the shit? :)

1

1 Answers

0
votes

You need to escape the content before appending it. try this:

$('#paginator').html('<%= escape_javascript( will_paginate(@students)) %>');

Just replace above code with your .append line.