Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Instead of using a multiselect box that is pre-populated use <a href="http://jqueryui.com/autocomplete/" rel="nofollow">jQueryUI Autocomplete</a> to filter the list server side and only return matches to the client (similar to the way the tag selection works on StackOverflow).</p> <p>There is a good example of selecting multiple values here <a href="http://jqueryui.com/autocomplete/#multiple-remote" rel="nofollow">http://jqueryui.com/autocomplete/#multiple-remote</a></p> <p>You can then save the results of the selections in the same way you would process a multiselect.</p> <p>To implement a hybrid approach where the first letter fetches terms from the server and then afterwards filters from those results, you could use the following (please note that this is completely untested):</p> <p>Add a global var to hold your results</p> <pre><code>var results_cache = []; </code></pre> <p>Use a hybrid source in your <code>autocomplete</code></p> <pre><code>source: function( request, response ) { // get the first letter of your search term var letter = request.term.substring(0,1); // check to see if we already have results for this letter if (!results_cache[letter]){ // no results, fetch via AJAX $.getJSON( "search.php", { term: request.term }, function(data){ // cache results results_cache[letter] = data; // filter results (in case we have more than just 1 character in the term) response($.ui.autocomplete.filter(data, request.term)); } ); } else { // we already have data for this letter, just filter the results from the cache response($.ui.autocomplete.filter(results_cache[letter], request.term)); } }, search: function() { // make sure we have at least 1 character for the term if (!this.value) return; var term = this.value; }, </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload