jQuery Autocomplete / django-ajax-selects: how to add selected item to a display area, and to allow creating new item?
I want to provide an Autocomplete feature that's similar to the example provided by django-ajax-selects:
user types apartment name in a textbox, a list of autocomplete suggestions is provided. Each suggestion includes unique_id, name, image, address, etc.
user can select from the list of suggestions. Once selected, details of that apartment is added to a display area below the textbox. There's also a "delete" icon to delete a selected apartment
If there's no match from the existing apartments in the database, user can create a new apartment
When the form is submitted, if it contains an unique_id, that id will be used to look up the existing apartment from the database. If the form doesn't contain an unique id, a new database entry will be created using the data entered by the user
django-ajax-selects
is built using jQuery Auto开发者_开发百科complete, but the above functionality is quite different from the standard behavior of jQuery Autocomplete and I can't quite figure out how to make the javascript works.
How do I use jQuery Autocomplete to implement this feature? Any help is greatly appreciated. Thanks.
精彩评论