]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete: code improvements for multiple demo
authorjzaefferer <joern.zaefferer@gmail.com>
Thu, 15 Apr 2010 13:31:49 +0000 (15:31 +0200)
committerjzaefferer <joern.zaefferer@gmail.com>
Thu, 15 Apr 2010 13:31:49 +0000 (15:31 +0200)
demos/autocomplete/multiple.html

index 5fef4bad249866252206641df9609e9ca5a92f42..5e0f4b50b7ad3169d18280c1436c1a2d162dca20 100644 (file)
@@ -16,7 +16,7 @@
                        return val.split(/,\s*/);
                }
                function extractLast(term) {
-                       return split(term)[split(term).length - 1];
+                       return split(term).pop();
                }
                
                $("#birds").autocomplete({
@@ -27,7 +27,7 @@
                        },
                        search: function() {
                                // custom minLength
-                               var term = extractLast($(this).val());
+                               var term = extractLast(this.value);
                                if (term.length < 2) {
                                        return false;
                                }
                                return false;
                        },
                        select: function(event, ui) {
-                               var terms = split( $(this).val() );
+                               var terms = split( this.value );
                                // remove the current input
                                terms.pop();
                                // add the selected item
                                terms.push( ui.item.value );
                                // add placeholder to get the comma-and-space at the end
                                terms.push("");
-                               $(this).val( terms.join(", ") );
+                               this.value = terms.join(", ");
                                return false;
                        }
                });