Active Admin's pagination on index pages is great, but we are trying to allow the user to type in the desired page number (in addition to the clickable page buttons).
Their desire is to have a prompt like "Enter Page Number:" and an input box where they can type in the desired page number.
Anyone done this already, or have ideas on how to proceed?
You can create a custom sidebar section like this:
sidebar :jump_to_page do
input :page_number
input type: :submit
end
Then add this to you active_admin.js.coffee file:
$ ->
$("#page_number_submit").on 'click', (e) ->
page_number = $("#page_number").val()
if window.location.search.indexOf("page=") > 0
window.location.search = window.location.search.replace(/page=\d*/, "page=#{page_number}")
else if window.location.search.indexOf("?") == 0
window.location.search = window.location.search + "&page=#{page_number}"
else
window.location.search = "page=#{page_number}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With