limit_tag_js  JavaScript Setup Required!
The limit_tag_js allows the user to select any arbitrary limit per page, up to the :client_max_limit option. It raises an OptionError exception if the :client_max_limit is not truthy.
It works with all paginators but :keyset
<%== @pagy.limit_tag_js %>
Pagy requests the right page number
After selecting a new limit, pagy reloads the page that roughly contains the same items shown before the reload.
Console
require 'pagy/console'
=> true
>> puts @pagy.limit_tag_js(client_max_limit: 100)
<span class="pagy limit-tag-js" data-pagy="WyJzaiIsNDEsIi9wYXRoP2V4YW1wbGU9MTIzJnBhZ2U9UCAiXQ=="><label>Show <input name="limit" type="number" min="1" max="" value="20" style="padding: 0; text-align: center; width: 3rem;"><a style="display: none;">#</a> items per page</label></span>
=> nil
>> puts @pagy.limit_tag_js(client_max_limit: 100, id: 'my-elector', item_name: 'Products')
<span id="my-elector" class="pagy limit-tag-js" data-pagy="WyJzaiIsNDEsIi9wYXRoP2V4YW1wbGU9MTIzJnBhZ2U9UCAiXQ=="><label>Show <input name="limit" type="number" min="1" max="" value="20" style="padding: 0; text-align: center; width: 3rem;"><a style="display: none;">#</a> Products per page</label></span>
=> nil
anchor_string: 'data-turbo-frame="paginate"'- Concatenate a verbatim raw string to the internal HTML of the anchor tags. It must contain properly formatted HTML attributes. It's not suitable for
*_hashhelpers. absolute: true- Makes the URL absolute.
path: '/my_path'- Overrides the request path in pagination URLs. Use the path only (not the absolute URL). (see Override the request path)
fragment: '...'- URL fragment string.
querify: tweakSet it to a
Lambdato directly edit the passed string-keyed params hash itself. Its result is ignored.tweak = ->(q) { q.except!('not_useful').merge!('custom' => 'useful') }
Overriding *_js helpers is not recommended
The *_js helpers are tightly coupled with the JavaScript code, so any partial overriding on one side would be quite fragile and might break in future releases.