当用户联合会话过期时,Typeahead停止工作,我希望能在“远程”调用Typeahead失败时执行某个操作。特别是对于Typeahead,如何处理这种情况?是否有类似于典型ajax调用中找到的“错误”回调?以下是我目前拥有的代码:
var hints = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("value"),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: "/ProjectAssociation/CountryLookup?query=%QUERY",
wildcard: "%QUERY"
}
});
$("#assocStoragesSelection").typeahead(null, {
name: "nations",
limit: 90,
valueKey: "ShortCode",
displayKey: "Name",
source: hints,
templates: {
empty: [
"<div class='noitems'>",
"No Items Found",
"</div>"
].join("\n")
}
});