Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!