partial update create page quick search
This commit is contained in:
21
resources/js/quick-search/index.js
Normal file
21
resources/js/quick-search/index.js
Normal file
@@ -0,0 +1,21 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const searchBtn = document.getElementById("searchBtn");
|
||||
const searchInput = document.getElementById("searchInput");
|
||||
|
||||
searchBtn.addEventListener("click", function () {
|
||||
const keyword = searchInput.value.trim();
|
||||
if (keyword !== "") {
|
||||
// Redirect to the route with query parameter
|
||||
window.location.href = `/search-result?keyword=${encodeURIComponent(
|
||||
keyword
|
||||
)}`;
|
||||
}
|
||||
});
|
||||
|
||||
// Optional: trigger search on Enter key
|
||||
searchInput.addEventListener("keydown", function (e) {
|
||||
if (e.key === "Enter") {
|
||||
searchBtn.click();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user