从TypeScript调用TypeAhead方法
我想调用TypeScript模块中的TypeAhead库。如何实现与下面的脚本类似的脚本从TypeScript调用TypeAhead方法,typescript,Typescript,我想调用TypeScript模块中的TypeAhead库。如何实现与下面的脚本类似的脚本 /// <reference path="typings/jquery/jquery.d.ts" /> /// <reference path="typings/typeahead/typeahead.d.ts" /> $ReferrerSearchInput.typeahead({ hint: false, highlight: false, minLen
/// <reference path="typings/jquery/jquery.d.ts" />
/// <reference path="typings/typeahead/typeahead.d.ts" />
$ReferrerSearchInput.typeahead({
hint: false,
highlight: false,
minLength: 3
},
{
name: "Referrers",
display: "DisplayValue",
source: referrersDatasource,
limit: 20,
templates: {
suggestion: function(data) {
return data.FullName;
}
}
});
//
///
$refererSearchInput.typeahead({
提示:错,
推荐理由:错,
最小长度:3
},
{
名称:“推荐人”,
显示:“显示值”,
来源:referersdatasource,
限额:20,
模板:{
建议:功能(数据){
返回data.FullName;
}
}
});
我就是这样解决的:
const datasource = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: "MyUrl%QUERY",
wildcard: "%QUERY"
}
});
const inputOptions = {
hint: true,
highlight: true,
minLength: 0
};
const apiSettings = {
name: "DisplayName",
display: "Name",
source: datasource,
limit: 20,
templates: {
empty: "",
suggestion(data: any) {
return "";
}
}
};
$ReferrerSearchInput.typeahead(inputOptions, apiSettings);