Answer the question
In order to leave comments, you need to log in
How to handle onkeyup event and process in Node JS?
I am writing the server part in Node.JS
, using a plugin express
and a view engine handlebars
.
There is a request processing at the root address:
exports.index = function (request, response) {
let searchValue = request.body.input;
response.render('index.hbs', {
title: 'Gifts main page',
text: 'This is the left box',
gifts: searchGiftCertificates(searchValue)
});
}
index.hbs
Using an expression {{{body}}}
, a template is included in the
file header.hbs
, which: input
(search string) with an event onkeyup
:<input id="search" onkeyup="searchGiftCertificates()" placeholder="Search by item name">
{{#each gifts}}
onkeyup
on the Node.JS side or how to do it? You need to take the value of the field input
by event onkeyup
and somehow transfer it to Node JS in order to exports.index = function (request, response) {
process and pass the data (JSON) to the expression in the function above gifts: searchGiftCertificates(searchValue)
to handlebars
display the data on the page, in accordance with the search query.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question