问题描述
我整个下午都在与ajaxChosen进行修补,因为我喜欢Chosen,但是我的期权价值设定变得太大了.我还尝试了select2,但是速度太慢了.
I've been tinkering all afternoon with ajaxChosen, because I love Chosen, but my option value sets are getting too large. I've also experimented with select2, but it's just too darn slow.
http://harvesthq.github.io/chosen/ https://github.com/meltingice/ajax-chosen
因此,我已经选择了最新版本(1.1.0),以及最新版本的ajaxChosen.我将ajaxChosen初始化如下:
So, I've got the newest version of chosen (1.1.0), and the latest version of ajaxChosen. I initialize ajaxChosen as follows:
$("#add_people").ajaxChosen({
type: 'GET',
minTermLength: 3,
afterTypeDelay: 300,
dataType: 'json',
url: 'http://cmcrm.chocolata.be/content/people.php?action=list_options'
}, function (data) {
var results = [];
$.each(data, function (i, val) {
results.push({ value: val.value, text: val.text });
});
return results;
});
我的脚本可以访问此URL,并且由于我的脚本与远程URL在同一域中,因此没有进行XSS预防.
My script has access to this URL, and there is no XSS-prevention going on since my script is on the same domain as the remote url.
我的JSON格式如下:
The format of my JSON is as follows:
[{"value":3,"text":"Valerietje Mortelmans (Actief)"},{"value":9,"text":"Olivier Hopchet (Actief)"},{"value":13,"text":"Wieland Rits (Actief)"},{"value":14,"text":"Melissa Seiffert van der Merwede (Actief)"},{"value":15,"text":"Guillaume de Valensart (Actief)"},{"value":18,"text":"Xavier Cloet (Actief)"},{"value":19,"text":"Brent Lammens (Actief)"},{"value":21,"text":"Coralie Libert (Actief)"},{"value":22,"text":"Laetitia Theus (Actief)"},{"value":23,"text":"Evelien Mollet (Actief)"},{"value":24,"text":"Feya Smets (Actief)"},{"value":25,"text":"Michelle Warneke (Actief)"},{"value":26,"text":"Carolyn Spaenjaers (Actief)"},{"value":27,"text":"Evelien Raes (Actief)"},{"value":28,"text":"Ange Luyten (Actief)"}]
我看到所选内容已初始化,但是当我开始键入内容时,我立即得到没有针对KEYWORD的搜索结果".我的控制台没有错误.
I see that chosen has initialized but when I start typing I immediately get "No search results for KEYWORD". There are no errors in my console.
那是什么问题?插件不起作用吗?还是我做错了什么?
So what's the problem? Does the plugin just not work? Or am I doing something wrong?
任何人都可以提供帮助,这样我就不会浪费更多时间了吗? :-)很想使用这个.谢谢!
Can anyone assist so that I don't waste more time on this? :-) Would love to use this. Thanks!
推荐答案
进一步研究后,我发现该插件不再受积极支持.
After some further research I found out that this plugin isn't actively supported anymore.
似乎迈克尔·佩林(Michael Perrin)对其进行了分叉,使其与所选的1.X版本兼容: https://github.com/michaelperrin/ajax-chosen/
It seems that Michael Perrin forked it to be compatible with 1.X versions of chosen:https://github.com/michaelperrin/ajax-chosen/
Michael的fork可以工作,但是仍然有点麻烦.在Michael的示例中,我的主要问题是找到匹配结果后,会丢弃某些键入的字母.意外的行为!
Michael's fork works, but still is a bit buggy. In the example of Michael, my main problem was that some typed letters were being dropped after a matching result was found. Unexpected behavior!
也许最好再给 Select2 一次机会,因为它的用户声称可以规避处理大型列表时,插件的延迟.
Maybe it would be best to give Select2 another chance, since its users claim that they can circumvent the lagginess of the plugin, when dealing with large lists.
此插件受到积极支持,并得到广泛使用.也许最好把鸡蛋放在那个篮子里;-)
This plugin is supported actively and is widely used. Maybe it would be best to lay our eggs in that basket ;-)
可以在此处找到有关Select2速度慢的问题.
The issues about slowness of Select2 can be found here.
这篇关于ajaxChosen插件将不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!