JQuery tokenInput (tags) : 我如何过滤来自网络服务的结果?它总是显示所有项目

JQuery tokenInput (tags) : how do i filter results from webservice? It always displaying all items

我有一个 .tokenInput,它对从我的网络服务返回的数据执行 search/autocomplete;这很好用..

我的问题是,无论我在搜索什么,它总是 returns 来自网络服务的所有项目,而不是过滤掉那些不符合我正在输入的 searchstring/tagname 的项目...

...因此我尝试修改 onResult: 事件中的返回结果,但没有成功...

关于返回数据:

X [对象] 的数组,其中每个对象包含 idname

还有...有趣的部分(脚本)

$("#articleTags").tokenInput("api/Article/GetClubTags", {
    crossDomain: false,
    prePopulate: $(this).data("pre"),
    theme: "facebook",
    preventDuplicates: false,
    allowFreeTagging: true,
    tokenValue: 'name',
    onResult: function (items) {
        if ($.isEmptyObject(items)) {
            return [{ id: '0', name: $("tester").text() }];  // if tag not found on server (this works)..
        } else {
            var tagsearch = $("tester").text();  // for example "Norway".

            var arrayMatch = items.forEach(function (itm) {
                if (itm.name === tagsearch) {
                    console.log("FOUND > " + itm.name);  // output works when i type in the correct string
                    return itm;
                }
            });
            console.log(items);
            return items; // just displaying all items, not filtering out those who does not match the string.
        }
    }
});

实际上...我自己想出了解决方案,并用查询参数等进行了更多小时的测试:

解决方案是 function-call 获取键入的值并像这样组成 api url:

function callWebServiceUrl() {
    return "api/Article/GetClubTags/" + $("tester").text();
}

$("#articleTags").tokenInput(callWebServiceUrl, {
    crossDomain: false,
    prePopulate: $(this).data("pre"),
    theme: "facebook",
    preventDuplicates: false,
    allowFreeTagging: true,
    tokenValue: 'name',
    onResult: function (item) {
        if ($.isEmptyObject(item)) {
            return [{ id: '0', name: $("tester").text() }];
        } else {
            return item;
        }
    },