jQuery input picker plugin filter results is not getting to normal after deleting a value from input
I have this php code in items_select.php file
<?php
require_once '../init.php';
$data = [];
$q = ((isset($_GET['q']) && $_GET['q'] != '')?sanitize($_GET['q']):'');
$item_select = $db->query("SELECT * FROM products WHERE itemNo LIKE '$q%' OR title LIKE '$q%'");
while($item = mysqli_fetch_assoc($item_select)){
$data[] = $item;
}
echo json_encode($data);
?>
and in invoice.php I have the jQuery/javascript code
<script>
$(document).ready(function () {
$('input#items').inputpicker({
url: 'parsers/items_select.php',
fields:['itemNo','title'],
fieldText:'title',
fieldValue:'id',
headShow: true,
filterOpen: true,
autoOpen: true
});
});
</script>
Now everything is working fine except, when I type/search/filter in the input a text or a value that is available in the options and I didn't select it, I just deleted it in the input, the search/filter results are not going back to normal which is showing every option. This is after I type in the input and delete it
This is after I reload the page, I have 2 results already
and btw, this only happens when using ajax call/JSON - Remote Search
Via Active questions tagged javascript - Stack Overflow https://ift.tt/n9Lbek7
Comments
Post a Comment