-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initialising filters does not seem to work with AJAX #525
Comments
Hi @MrTobyDog! I have already isolated the problem. Basically every time the pager updates, it tries to make sure that a parameter has changed before sending a request out to the server. These checks include, the current page, size, total pages, sort and filters. The problem was that with empty filters, the value would initially be set to ['Smith', '', ''].join('') === ['', 'Smith', ''].join(''); // true
['Smith', '', ''].join(',') === ['', 'Smith', ''].join(','); // false so, the pager would compare the empty array versus an array of empty strings and think it was a different search, and allow the second call to go through to the server. [].join(',') === ['', '', ''].join(',') // false So, I have fixed this by adding these two lines above the comparison which normalizes the array of empty strings (in both the pager plugin & pager widget): // fixes issue where one currentFilter is [] and the other is ['','',''],
// making the next if comparison think the filters are different (joined by commas). Fixes #202.
l.currentFilters = (l.currentFilters || []).join('') === '' ? [] : l.currentFilters;
p.currentFilters = (p.currentFilters || []).join('') === '' ? [] : p.currentFilters;
// don't allow rendering multiple times on the same page/size/totalpages/filters/sorts
if ( l.page === p.page && l.size === p.size && l.totalPages === p.totalPages &&
(l.currentFilters || []).join(',') === (p.currentFilters || []).join(',') &&
l.sortList === (c.sortList || []).join(',') ) { return; } I'll have this available in the next update. |
Thanks for quick response - I have patched the code and that seems to have On 4 March 2014 11:44, Rob G [email protected] wrote:
|
That is yet another thing I broke in version 2.15.0 (see issue #511)... Originally, you would set the <th data-value=">20">Value</th> this data-attribute can be modified by the This demo will work once the next update is available. |
Thanks On 4 March 2014 13:22, Rob G [email protected] wrote:
|
Great plugin which I have used for a while but just started to get more adventurous with pager and filters!
I have looked at http://jsfiddle.net/Mottie/abkNM/785/ and tried to replicate the code:
But it does not seem to work, I am using the pager option with an AJAX call and the AJAX is always called (twice as I have reported in another issue) with no filters, and the filter boxes contain no text. I wondered if filter_liveSearch was the issue but makes no difference whether set or not as far as I can tell.
The text was updated successfully, but these errors were encountered: