Open navigation

How to remove search event from a specific search box?

By default, Klevu associates the event (provide search suggestions) to every text box having name="q" or id="search", if there are any search boxes e.g. blog search box and you don't want Klevu to power the searches for the specific search box, here is the solution:

Option 1:

A simple & the quick solution is to change the name (other than "q") and id (other than "search").

Option 2:

If above is not possible, we suggest adding the following JS function before end of </body>.
Please do remember to change <id-of-search-box> with an actual id of the search box from below function.

<script>// <![CDATA[
function removeKlevuEventHandlersForSearchBox(searchBoxId){
if( 'undefined' !== typeof klevu_storeSearchBoxes && klevu_storeSearchBoxes &&
klevu_storeSearchBoxes.length > 1 && document.getElementById(searchBoxId) ){
var element = document.getElementById(searchBoxId),
clone = element.cloneNode();
while (element.firstChild) {
//element.form.action = "<form-action>";
element.parentNode.replaceChild(clone, element);

//Attach any required event handlers to the clone
} else{
setTimeout( function(){ removeKlevuEventHandlersForSearchBox(searchBoxId); }, 300 );

// ]]></script>

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.