javve / list.pagination.js

A pagination plugin for List.js
24 stars 23 forks source link

On searching the list, the pagination disappears #2

Closed tnguyen14 closed 10 years ago

tnguyen14 commented 10 years ago

When I perform a search, the pagination ul disappears. Is there any reason why this might be the case?

mamort commented 10 years ago

I also struggled with this problem. The problem is that the paging module creates a new List.js list to represent the pages themselves. That is, a new List() that represents the ul..li items. Confusing...yes. This new List representing the pages is created with many of the same options as the primary list of items you are trying to display. This means that it will inherit the "listClass" property and use the same default values for many of the other options as for instance the "searchClass" property. Using the same default value for "searchClass" as the primary list is why the pagination disappears when a search is performed. When you perform a search it will effectively filter BOTH your primary list of items and the pagination list containing only the list of pages. Of course the items in the pagination list will never match your search so the pagination just disappears (or is displayed with zero items in it).

This is a bug. The pagination list should make sure that it cannot share any features (like searching/sorting etc) with the primary list that is displayed. A workaround is to setup your list with a custom value for "searchClass". The default value for the "searchClass" is "search" so change it to something else. When you do this the pagination list will continue to use "search" as its "searchClass" and will not be affected by searching your primary list.

tnguyen14 commented 10 years ago

Thanks @mamort for the awesomely detailed answer.

@sindresorhus uses a paging plugin on the bower components website, and in his source code https://github.com/sindresorhus/bower-components/blob/gh-pages/js/main.js I don't see any weird handling of this issue. Do you know of that plugin?

tnguyen14 commented 10 years ago

And I just wanna confirm that using a non-default searchClass option solves the problem. Should this issue be closed or left open as a bug?

javve commented 10 years ago

Thanks a lot for finding and solve this bug! I've now update the to 0.1.1 and the problem should be gone :)