$('.cs-main-area .list-group').append("<%= escape_javascript render partial: 'package_list', locals: { packages: @packages, page: params[:page] } %>");

var newPagination;
<% if @packages.count > WillPaginate.per_page * ( params[:page] || '1' ).to_i %>
  newPagination = "<%= escape_javascript will_paginate @packages, class: 'pagination cs-full-width cs-no-margin cs-center' %>";
<% else %>
  newPagination = "<div class='pagination cs-full-width cs-no-margin cs-center'>";
  newPagination += "<%= escape_javascript link_to 'View all Packages', root_path(sort: params[:sort]) %>";
  newPagination += "</div>";
<% end %>

$('.pagination').replaceWith(newPagination);

$('.cs-main-area .list-group').append("<%= escape_javascript render partial: 'package_list', locals: { packages: @packages, page: params[:page] } %>");

var newPagination;
<% if @packages.count > WillPaginate.per_page * ( params[:page] || '1' ).to_i %>
  newPagination = "<%= escape_javascript will_paginate @packages, class: 'pagination cs-full-width cs-no-margin cs-center' %>";
<% else %>
  newPagination = "<div class='pagination cs-full-width cs-no-margin cs-center'>";
  <% if params[:search].present? %>
    newPagination += "<%= escape_javascript link_to 'View all Packages', root_path(sort: params[:sort]) %>";
  <% else %>
    newPagination += "<a href='#top'>Scroll to Top</a>";
  <% end %>
  newPagination += "</div>";
<% end %>

$('.pagination').replaceWith(newPagination);

$("a[href='#top']").click(function() {
  $("html, body").animate({ scrollTop: 0 }, "slow");
  return false;
});

Add "Scroll to Top" button to bottom of unsearched
Add "Scroll to Top" button to bottom of unsearched 