Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
Change reductive search to search submit

After having a few small wins with JS (still very much a learner) I have now inherited a task which is to change a reductive search of sorts.

Users now want to have the search work from a submit button, instead of a keyup after 3rd character. I have completed submit forms before where the form would post, but I have never come across something as complex as this before.

I have had a look through the large JS file, and located the search function which contains the keyup function.

  F.initSearch = function(opts){
    if(!opts || !opts.ele){
      return;
    }
  
    if(!opts.start_length){
      this.opts.search.start_length = 2
    }
  
    this.$search_ele = $(this.opts.search.ele);
  
    if(this.$search_ele.length){
      this.has_search = true;
      this.searchFn = this.buildSearchFn(opts.fields);
      this.bindEvent(opts.ele, 'keyup');
    }
  };

However, I am having difficulty with changing over from keyup to button click.

This is what I have done:

I have updated the form to include the button

   <form>
       <div class="searchBox">
         <input type="text" id="search" class="search__text-input" placeholder="Search"/>
       </div>
      
       <div class="formBox">
           <button id="searchbtn">Search</button>
       </div>     
   </form>

I have tried to update the script with some jquery which follows the same pattern

$( "#searchbtn" ).this.bindEvent(opts.ele, 'click');

Lastly, I have attempted to then update the existing - which is now leaving me somewhat defeated:

F.initSearch = function(opts) {
    if(!opts || !opts.ele) {
        return;
    }
    if(!opts.start_length) {
        this.opts.search.start_length = 2
    }
    this.$search_ele = $(this.opts.search.ele);
    if(this.$search_ele.length) {
        this.has_search = true;
        this.searchFn = this.buildSearchFn(opts.fields);
        // this.bindEvent(opts.ele, 'keyup');

/* Trying to swap keyup for button click */

        $( "#searchbtn" ).this.bindEvent(opts.ele, 'click');



    }
};

Link to JSFiddle: https://jsfiddle.net/mcmacca002/bo0y3u7p/2/

Clearly I am approaching this wrong, and some guidance would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda