问题
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