1rosehip / jplist

jPList jQuery Data Grid Controls is a flexible jQuery plugin for sorting, pagination and filtering of any HTML structure (DIVs, UL/LI, tables, etc).
http://jplist.com
Other
437 stars 177 forks source link

Search form .submit() and pagination jump to start #219

Closed vhanahrni closed 7 years ago

vhanahrni commented 7 years ago

Hi, thanks for your work.

Is it possible to have pagination jump to start on form submit ?

$("#menu-search-sku").submit(function() {
   //pagination jump to start
});

I use save plugin state. That's great for page reload, but plugin is initiated in a search's result page so each new search's result start from last saved page.

1rosehip commented 7 years ago

Please consider using data-control-storage="false" attribute: http://jplist.com/documentation/control-settings/pagination

It allows to exclude the pagination control from the storage.

vhanahrni commented 7 years ago

I read the documentation. Using data-control-storage="false" exclude the pagination from the storage. I need to save the pagination to retrieve the state when going back from detail page to result page, and I need to to have pagination jump to start on new search (on form submit). I ask this question as for example : A search's result has 100 items, pagination is set to 10 items per page. I navigate to page 3. Then I make a new search and new search's result has 90 items : the page shown is the third page.

1rosehip commented 7 years ago

You can try the following JS after a new search:

$('.jplist-pagination [data-number="0"]').eq(0).trigger('click')
vhanahrni commented 7 years ago

Thank you very much for your answer. The final code is below

$("#menu-search-sku").submit(function() {
   //pagination jump to start
   $('.jplist-pagination [data-number="0"]').eq(0).trigger('click')
});

Other solution is to use your previous answer ( using data-control-storage="false" ) with deep linking.

1rosehip commented 7 years ago

You're welcome 👍