From 7b7f866582900992bd99b8d2505387109c733911 Mon Sep 17 00:00:00 2001 From: Junior Date: Mon, 16 Dec 2024 11:19:39 -0500 Subject: [PATCH] Do a new getContents if the search field is cleared --- js/books.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/books.js b/js/books.js index f5794f9..e0487ae 100644 --- a/js/books.js +++ b/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,