I'm currently using the Turbolinks.visit
action with the help of $(document).on("input");
...
HTML
<form id="mainSearch" method="get" autocomplete="off">
<input type="search" name="s" placeholder="Search" />
</form>
Javascript
$(document).off().on("input", "#mainSearch", function(e) {
e.stopImmediatePropagation();
e.stopPropagation();
e.preventDefault();
var searchQuery = $(this).serialize();
setTimeout(function(){
Turbolinks.visit(
homeurl+"/?"+searchQuery,
{
change: ['content']
}
);
},110);
return false;
});
Everything seems to be working correctly, but multiple requests are triggered when holding down a key.
https://i.sstatic.net/fP8PE.png
How can I prevent it from sending multiple requests while keeping the key pressed? .on("input"