Skip to content

Instantly share code, notes, and snippets.

@michalkorzawski
Last active August 15, 2022 14:38
Show Gist options
  • Save michalkorzawski/efbc3134f6d7f991529f92ed0b65620d to your computer and use it in GitHub Desktop.
Save michalkorzawski/efbc3134f6d7f991529f92ed0b65620d to your computer and use it in GitHub Desktop.
def results
params_hash = element.dataset['params-hash'].present? ? JSON.parse(element.dataset['params-hash']) : filtered_params
pagy, collection = pagy(active_record_collection(filters), page: page)
# The HTML provided can be a partial or ViewComponent (as we use in our case)
cable_ready.morph(
children_only: true,
selector: '#id_of_a_dom_element',
html: render(
PaginationComponent.new(
pagy: pagy,
params_hash: params_hash.to_json,
collection: collection
), layout: false
)
)
morph :nothing
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment