paginationjs icon indicating copy to clipboard operation
paginationjs copied to clipboard

[SOLVED]Input field filtering not working

Open 3rc4n opened this issue 6 years ago • 4 comments

I am trying to use text filtering with ajax, entered in a text field.

[...] dataSource: 'myScript.php', data: { 'filter' : $('#textfield').val() }, ajax: { 'method': 'GET', [...] } [...]

When I type something in the field and press a Go-Button, I am using the Go-Feature of paginationjs (going to page 1), but the Filter-Value stays empty even after I typed something in. Once I press F5 on Firefox, it keeps the entered value in that field, and suddenly it posts the value to the dataSource (some php file on the server).

I even tried beforeSend to modify data, but the url-value does not change automatically.

Any chance to get this working?

3rc4n avatar Oct 30 '19 21:10 3rc4n

Could you please provide a re-produciable demo: http://codepen.io/superRaytin/pen/RRoZBz

superRaytin avatar Nov 12 '19 07:11 superRaytin

Okay, I made it.

I got a input field (text) and a button.

Once I click the button, I re-initialize my pagination-container by adding the textfield value onto the dataSource-URL.

3rc4n avatar Nov 27 '19 20:11 3rc4n

Can we get more information on this? I am trying to do something similar (with a select). I load the initial results with the below:

container.pagination({ dataSource: '/api/path/' + $('#filter').val(), ... })

Then, when trying to reload the data with filtered results:

$('#filter').change(function() { ? }

ksorensen76 avatar Jan 23 '20 17:01 ksorensen76

For other people having a similar question, I solved this by setting my default pagination options in a var:

var options = {
  dataSource: /url,
  locator: 'results',
  pageSize: '20',
  ...
}

Then in the .change:

$('#filter').change(function() {
  container.pagination({
    ...options,
    dataSource: options.dataSource + '?filter=' + $('#filter').val()
  });
}

ksorensen76 avatar Jan 24 '20 20:01 ksorensen76