I have this line of codes that will get the entire location in my database when a user types in text in my text box. The problem is that I want to check when the user changes the text in my text box and does not exist in my typeahead?
var path = "{{ route('search.location') }}"; $('input.typeahead').typeahead({ source: function (query, process) { return $.get(path, { query: query }, function (data) { return process(data); }); } }).blur(function () { if(source.indexOf($(this).val()) === -1) alert('Not exists'); });
I did some research using the .blur function, but I can't get it to work?
ReferenceError: source is not defined
source share