Pre-defined Ajax Select (v4)

24 views
Skip to first unread message

Jeff Conklin

unread,
May 26, 2016, 3:38:09 PM5/26/16
to select2
Hello,

I have been searching for the answer to a situation I have ran into but I am either searching for the wrong thing or it has not been discussed. So here I am :)

I am using the AJAX integration for a select box that we have in a small. I would like to find a way to pre-populate the area where they are typing with either their previous search, or really anything specific I define. An example:

- Go to the "Loading remote data" example section: https://select2.github.io/examples.html#data-ajax
- Click the "select2/select2" selectbox and type "select2". Choose any of the suggestions displayed.
- Click the select box again to search again.
- Instead of it being blank, I would like "select2" (the last thing typed) to be displayed... http://imgur.com/4AuaEW2  I would also hope that the ajax call is also fired at that time for quick and seamless access to the returned data.

My specific need for this is all about making my forms easier to use. On our small form, an admin can type in an email or username into the select and the system returns back matching users. A search for (lets say) "Stephen" may return multiple users that the admin can select. In many situations, the admin may select the first displayed user, review their data, and quickly want to select the second "Stephen" in the list. Right now they have to retype Stephen. Though it is not the end of the world, being able to perform the last search again (without retyping) would help the usability of this feature a good bit.

Any direction would be great. And I do apologize if I missed a previously discussed solution.

Thanks!
Reply all
Reply to author
Forward
0 new messages