Manipulate search form from outside
Submit search form
If you have a 'search' button outside of the search form, Findify will not automatically use it to submit the search.
You can take a look at the following example to see how this can be done
$(function() {
$(BUTTON_SELECTOR).on("click", function(e){
e.preventDefault();
var submitEvent = document.createEvent("HTMLEvents");
submitEvent.initEvent('submit', true, true);
$(FORM_SELECTOR)[0].dispatchEvent(submitEvent);
});
});
Open autocomplete form
This is useful for mobile if you don't have a search input but want to open the autocomplete by clicking on some button
$(function() {
$(BUTTON_SELECTOR).on("click", function(e){
e.preventDefault();
var clickEvent = document.createEvent("HTMLEvents");
clickEvent.initEvent('focus', true, true);
$(FORM_SELECTOR)[0].dispatchEvent(clickEvent);
});
});
Updated over 7 years ago