Skip to Content


Enable autocomplete search on core WordPress input field selectors.

JavaScript February 16, 2021


This function runs automatically, so it is not called manually. Is this incorrect?


Prevent default Nebula autocomplete on a search field. This is also useful for overriding the default Nebula autocomplete in favor of customized parameters.

<input id="s" class="no-autocomplete" type="text" placeholder="Search this website..." />

Additional Notes

This function runs on all input fields with an ID of s or a class of search.

To prevent an autocomplete on a certain input, use the class no-autocomplete.


Source File

Located in /assets/js/modules/search.js on line 98.

1 Hook

Find these filters and actions in the source code below to hook into them. Use wp.hooks.doAction() and wp.hooks.addFilter() in your JavaScript file.

Need a new filter hook? Request one here.

This function has no action hooks available. Request one?

nebula.autocompleteSearchListeners = async function(){
    let autocompleteSearchSelector = wp.hooks.applyFilters('nebulaAutocompleteSearchSelector', '.nebula-search input, input#s,');
    jQuery(autocompleteSearchSelector).one('focus', function(){ //Only do this once
        if ( !jQuery(this).hasClass('no-autocomplete') ){ //Use this class to disable or override the default Nebula autocomplete search parameters
            nebula.loadJS(, 'jquery-ui').then(function(){
                nebula.dom.document.on('blur', '.nebula-search input', function(){

                //I do not know why this cannot be debounced
                jQuery('input#s,').on('keyup paste', function(e){
                    let allowedKeys = ['Backspace', 'Delete']; //Non-alphanumeric keys that are still allowed to trigger a search

                    if ( jQuery(this).val().trim().length && (nebula.isAlphanumeric(e.key, false) || allowedKeys.includes(e.key) ) ){
                        let types = false;
                        if ( jQuery(this).is('[data-types]') ){
                            types = jQuery(this).attr('data-types');

                        nebula.autocompleteSearch(jQuery(this), types);
                    } else {
                        jQuery(this).closest('.input-group').find('.fa-spin').removeClass('fa-spin fa-spinner').addClass('fa-search');



To override or disable this JavaScript function, simply redeclare it with the exact same function name.

nebula.autocompleteSearchListeners = function(){
    //Write your own code here, leave it blank, or return false.