Do a new getContents if the search field is cleared
This commit is contained in:
parent
851b5156d7
commit
7b7f866582
10
js/books.js
10
js/books.js
|
@ -2,6 +2,7 @@
|
|||
var kindlemail = "";
|
||||
var currentpath = "";
|
||||
var searchTimeout = null;
|
||||
var lastSearch = "";
|
||||
|
||||
$(document).ready(function() {
|
||||
getContents();
|
||||
|
@ -35,6 +36,10 @@ $(document).ready(function() {
|
|||
$("#search").on("change keyup", function() {
|
||||
if ( searchTimeout ) clearTimeout(searchTimeout);
|
||||
if ( $("#search").val().length > 2 ) searchTimeout = setTimeout(getContents, 500);
|
||||
if ( ($("#search").val() == "") && (lastSearch != "") ) {
|
||||
lastSearch = "";
|
||||
getContents();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -50,7 +55,10 @@ function redirectToLogin() {
|
|||
function getContents() {
|
||||
if ( searchTimeout ) clearTimeout(searchTimeout);
|
||||
var data = {};
|
||||
if ( $("#search").val() != "" ) data.search = $("#search").val();
|
||||
if ( $("#search").val() != "" ) {
|
||||
data.search = $("#search").val();
|
||||
lastSearch = data.search;
|
||||
}
|
||||
$.ajax({
|
||||
url : 'ajax/getcontents.php',
|
||||
data : data,
|
||||
|
|
Loading…
Reference in New Issue
Block a user