]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete (combobox demo): Set intial value of text field based on value of select...
authorScott González <scott.gonzalez@gmail.com>
Tue, 20 Jul 2010 18:49:14 +0000 (14:49 -0400)
committerScott González <scott.gonzalez@gmail.com>
Tue, 20 Jul 2010 18:49:14 +0000 (14:49 -0400)
demos/autocomplete/combobox.html

index c76cfa1305b4513c80b18f74051230ffbe176b71..1b7b668a92ded982ec8d7a078f65a05a4c9ae2e0 100644 (file)
                $.widget( "ui.combobox", {
                        _create: function() {
                                var self = this;
-                               var select = this.element.hide();
+                               var select = this.element.hide(),
+                                       selected = select.children( ":selected" ),
+                                       value = selected.val() ? selected.text() : "";
                                var input = $( "<input>" )
                                        .insertAfter( select )
+                                       .val( value )
                                        .autocomplete({
                                                delay: 0,
                                                minLength: 0,