如何排除某些具有特定数组的对象,使其不会出现在Twitter提前搜索栏中?这是使用TMDb的电影搜索数据库网站的《猎犬》和《 Typeahead》的JS:
var movies = new Bloodhound({
datumTokenizer: function (datum) {
return Bloodhound.tokenizers.whitespace(datum.value);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
wildcard: '%QUERY',
url: 'http://api.themoviedb.org/3/search/movie?query=%QUERY&api_key=...',
transform: function (response) {
return $.map(response.results, function (movie) {
return {
valueID: movie.id,
valueTitle: movie.title,
valueStatus: movie.status
};
});
}
}
});
$('.typeahead').typeahead({
hint: true,
highlight: true,
minLength: 1,
autoselect: true
},
{
name: 'movieDataset',
display: "valueTitle",
source: movies,
templates: {
suggestion: function (movie) {
return '<p>' + movie.valueTitle + ' - ' + movie.valueYear + '</p>';
},
empty: function (movie) {
$(".tt-dataset").text('No Results Found');
}
}
}).bind('typeahead:select', function(ev, suggestion) {
$('#movieid').val(suggestion.valueID);
});
以下是其中一个对象的JSON的样子:
{"id":347031,
"title":"Swiss Army Man",
"status":"Released"}
我想知道如何从预输入中排除所有以“计划”作为其“状态”的对象。你知道我该怎么做吗?抱歉 对于错误的术语,我对此很陌生。谢谢!