Making a tag suggestion using jQuery chosen plugin

柔情痞子 提交于 2019-12-24 09:38:08

问题


I am using jquery chosen plugin https://github.com/harvesthq/chosen/ to make my select form fields pretty. Here is the demo page for chosen plugin https://github.com/harvesthq/chosen

I was thinking if it is possible to make tags like stackoverflow using chosen plugin because some of its feature looks alike. I am also like to know how do i use chosen with ajax to add tag suggestions.

I could use one of those jquery tags out there but i would like to know if i can do it using chosen so i don't need to add another script with my page.

Let me know if you need to know anything more.


回答1:


All that you have to do is to modify the select box with an ajax request. Than use :

$("#form_field").trigger("list:updated");

to tell "chosen" that the list has been updated.




回答2:


Yes, all of what you ask is possible. From my answer to "Is there a way to dynamically ajax add elements through jquery chosen plugin?":

Take a look at the neat Select2 plugin, which is based on Chosen itself and supports remote data sources (aka AJAX data) and infinite scrolling.




回答3:


The koenpunt fork of chosen has the functionality you want. More info here



来源:https://stackoverflow.com/questions/8587295/making-a-tag-suggestion-using-jquery-chosen-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!