大佬教程收集整理的这篇文章主要介绍了jquery – Twitter的typeahead-bloodhound:使用ajax.data和POST时,“%QUERY”相当于什么?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
// Typeahead personsBloodhound = new Bloodhound({ datumTokenizer: function (person) { return person.name; },queryTokenizer: Bloodhound.tokenizers.whitespace,remote: { url: '/ajax/Persons/List?nameContains=%QUERY',ajax: { beforeSend: function(xhr) { $(".searching-person").show(); },data: { "pageSize": 4,"otherParam1": "blah","otherParam2": "bleh",} },filter: function (responsE) { $(".searching-person").hide(); return response.persons; } } });
一个只是在URL中使用%QUERY.
现在….
如果使用Bloodhound和POST,@R_520_10675@用什么而不是%QUERY?
// Typeahead personsBloodhound = new Bloodhound({ datumTokenizer: function (person) { return person.name; },remote: { url: '/ajax/Persons/List',ajax: { type: "POST",beforeSend: function(xhr) { $(".searching-person").show(); },data: { "nameContains": ....what GOES HERE?????...... "pageSize": 4,filter: function (responsE) { $(".searching-person").hide(); return response.persons; } } });
如果不清楚,问题是:
在Bloodhound的遥控器中使用POST时,%QUERY的等效值是多少?
文档不清楚,(证明):
https://github.com/twitter/typeahead.js/blob/master/doc/bloodhound.md#remote
还尝试使用:
"nameContains": $("#my-input-that-uses-typeahead").val(),
但没有奏效.
所以(“#my-input-that-uses-typeahead”).val()与动态URL结合使用(eghttp://127.0.0.1:1234 / REST_API / _search?uSELEss =%QUERY) ajax设置中的beforeSend-function.
我将提出有关此行为的问题.使用Bloodhound进行POST请求非常尴尬,并且带走了typeahead.js的简单性.
编辑:
还要确保在beforeSend中设置数据的新值并设置setTings.hasContent = true.否则将使用初始数据.
关于如何完成的示例:https://github.com/twitter/typeahead.js/issues/542#issuecomment-29995960.
以上是大佬教程为你收集整理的jquery – Twitter的typeahead-bloodhound:使用ajax.data和POST时,“%QUERY”相当于什么?全部内容,希望文章能够帮你解决jquery – Twitter的typeahead-bloodhound:使用ajax.data和POST时,“%QUERY”相当于什么?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。