[SOLVED]Input field filtering not working
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?
Could you please provide a re-produciable demo: http://codepen.io/superRaytin/pen/RRoZBz
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.
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() { ? }
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()
});
}