/** * Plugin functions file and typeahead * * Contains handlers for all the js functions that we will * be executing */ ( function( $ ) { // vars = als.ajaxurl als.nextNonce // url = ajaxurl&action=alsgetsuggestions&nextNonce=als.nextNonce //Typeahead if(als.load_suggestions == 'yes'){ var engine = new Bloodhound({ remote: { url: als.ajaxurl + '?s=%Q&action=alsgetsuggestions&nextNonce=' + als.nextNonce, wildcard:'%Q' }, queryTokenizer: Bloodhound.tokenizers.whitespace, datumTokenizer: Bloodhound.tokenizers.whitespace }); $('input[name="s"]') .typeahead( { minLength: 1, highlight: true }, { name: 'als-suggestions', source: engine, limit: 5, }) .bind( 'typeahead:render', function(e){ var input = $(e.target); var width = input.css("width"); input.siblings('.tt-menu').css({width: width}); } ); } /** * This function loads search results via ajax * @param string holds the value of the input box * @param div holds the div that displays the results */ function loadResults(str, div) { if(str.length==0) { return false; } div.html('