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

128
Views
Typeahead Bloodhound Do Something While Prefetch Is Happening

Bloodhound's prefetch feature is working great for me, but I would like to disable my inputs while the prefetch is happening.

Does anyone know of a way to detect when the prefetch is happening, do something, and then do something else when the prefetch is complete? Here is my code.

// Nav typeahead
var costCenters = new Bloodhound({
    datumTokenizer: Bloodhound.tokenizers.obj.whitespace('bloodhound'),        
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    prefetch: dsg_site_root + 'autocomplete/costCenterPullDownNamesComplete'
})

var employees = new Bloodhound({
    datumTokenizer: Bloodhound.tokenizers.obj.whitespace('bloodhound'),
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    prefetch: dsg_site_root + 'autocomplete/employeePullDownNamesComplete'
})

$(function() {    
    $('#navSearch').typeahead({
        highlight: true,
        maxItem: 20,
    },
    {
        name: 'costCenters',   
        display: 'display',   
        source: costCenters,
        templates: {
            header: '<h6 class="ml-3 mt-2 text-secondary">Cost Centers</h6>'
        }
    },
    {
        name: 'employees',  
        display: 'display',      
        source: employees,
        templates: {
            header: '<h6 class="ml-3 mt-2 text-secondary">Employees</h6>'
        }
    })

    $('#navSearch').bind('typeahead:select', function(ev, chosen) { 
        if(chosen.category == 'employees') {
            window.location.href = dsg_site_root + 'employee/index/' + chosen.id                
        } else {
            window.location.href = dsg_site_root + 'costCenter/index/' + chosen.id      
        }                               
    })         
})

Thanks in advance.

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!