'; }, footer: function(data) { messageObject.text("Suggestions are available, use up and down arrow keys to navigate"); } }, source: bloodhound.ttAdapter()	}).on('typeahead:open', function(evt) { messageObject.text("Type to get suggestions"); }).on('typeahead:select', function(evt, item) { populateinput(item); messageObject.text( "You have selected, ‘{0}’".format( displaykey(item) ) ); }).on('typeahead:change', function(evt, item) { t1 = inputObject.val(); if (t1!=selectedObjectText) { messageObject.text(""); clearinput(); } }).on('typeahead:autocomplete', function(evt, item) { populateinput(item); messageObject.text( "You have selected, ‘{0}’".format( displaykey(item) ) ); }).on('typeahead:render', function(evt, item,c,d) { if (typeof(item) != 'undefined') { messageObject.text("Suggestions are available, use up and down arrow keys to navigate"); } }).on('typeahead:close', function(evt) { var inputvalue = inputObject.typeahead('val'); if (bloodhound.remote.transport._cache.list.head) { var firstdoc = bloodhound.remote.transport._cache.list.head.val.response.docs[0]; } if ( typeof(selectedObjectText) != 'undefined' && selectedObjectText.length > 0 ) { messageObject.text( "You have selected, ‘{0}’".format(selectedObjectText) ); } else if ( typeof(inputvalue) != 'undefined' && inputvalue.length > 0 && typeof(firstdoc) != 'undefined') { // no selection then select the first docs var firstitem = { docid:firstdoc.docid, name:firstdoc.name, city_id:firstdoc.city_id, prov_cd:firstdoc.province_cd, prov_name:firstdoc.province_name, postalcode:firstdoc.postalcode }; //inputObject.val(displaykey(firstitem)); if (firstitem.docid.startsWith('PR')) { inputObject.typeahead('val',firstitem.prov_name); inputObject.val(firstitem.prov_name); } else if (firstitem.docid.startsWith('P')) { inputObject.typeahead('val',firstitem.postalcode); inputObject.val(firstitem.postalcode); } else { inputObject.typeahead('val',firstitem.name+", "+firstitem.prov_cd); inputObject.val(firstitem.name+", "+firstitem.prov_cd); } //inputObject.typeahead('val',firstitem.name); populateinput(firstitem); messageObject.text( "You have selected, ‘{0}’".format(displaykey(firstitem)) );	} else { messageObject.text(""); validSelection(); } });	}; function initCityprovSuggestObject() { $('div.ta-cityprovsuggest').each( function(i,obj) { new taCityprovSuggestFunctionsV2(obj); }); } if ($(".modify-job-wb-tabs").length) {	$(document).on("wb-ready.wb", initCityprovSuggestObject); } else { $(document).ready(initCityprovSuggestObject); } //]]> '; }); return '