I know that you mentioned earlier that it might be a performance issue to have live update on inputs so this live update is not implemented by default, but performance is not a problem in my scenario.
What I want to achieve is to have a live update on each keypress/ keyup (best would be to have at least two characters for the update results function to fire) andalso to redirect to the /search url on pressing the "enter key".
The last part works, but I struggle to find the callback to update the ajax results list on "keyup".
jQuery(document).ready(function($) {
//update results when typing (THIS PART LACKS THE UPDATE RESULTS CALL also it should only fire if the input is longer than 2)
$('#myinput').keyup(function() {
//UPDATE AJAX RESULTS
})
//redirect to search on pressing enter (THIS PART WORKS)
$('#myinput').keypress(function (e) {
var code = e.keyCode ? e.keyCode : e.which;
if (code.toString() == 13) {
redirectotosearch(); // call the function to redirect to another page
return false;
}
});
// Function that redirect the user to another page
function redirectotosearch() {
window.location = "/searchpage";
}
});
I'm not sure what other conversations you have had about this.
I take it you are talking about a View, and you want the View results to update as the user types into a search field.
It is not as simple as finding the right callback to use.
The search inputs are in a form, and updating the results—even via ajax—means updating the entire form, and the resulting ajax update replaces the current form as well as the View results.
I don't think what you want can be done using Views, it will require a custom solution for ajax submissions after each key press and handling of the returned matching posts to populate the results.
This is outside of our support policy, I'm afraid.
I can point you to tutorials about using ajax in the context of WordPress, such as hidden link