【发布时间】:2017-03-21 05:20:45
【问题描述】:
当用户在我的文本框中键入时,我有这行代码将获取我数据库中的所有位置。问题是我想验证用户何时更改我的文本框中的文本并且我的预输入中不存在?
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');
});
我已经使用.blur 函数进行了一些研究,但我无法让它工作?
ReferenceError: source is not defined
【问题讨论】:
标签: ajax twitter-bootstrap typeahead.js