]> source.dussan.org Git - jquery-ui.git/commitdiff
Combobox: Added a destroy method. Fixes #6685 - Combobox: Doesn't handle destroy.
authorScott González <scott.gonzalez@gmail.com>
Tue, 23 Nov 2010 13:22:40 +0000 (08:22 -0500)
committerScott González <scott.gonzalez@gmail.com>
Tue, 23 Nov 2010 13:22:40 +0000 (08:22 -0500)
demos/autocomplete/combobox.html

index c1407385a6a8cc135dd3cf4585a6e14aa5ddde49..ab939a0364d7b585ec0c19c44028815e1b32c719 100644 (file)
@@ -24,7 +24,7 @@
                                        select = this.element.hide(),
                                        selected = select.children( ":selected" ),
                                        value = selected.val() ? selected.text() : "";
-                               var input = $( "<input>" )
+                               var input = this.input = $( "<input>" )
                                        .insertAfter( select )
                                        .val( value )
                                        .autocomplete({
@@ -81,7 +81,7 @@
                                                .appendTo( ul );
                                };
 
-                               $( "<button>&nbsp;</button>" )
+                               this.button = $( "<button>&nbsp;</button>" )
                                        .attr( "tabIndex", -1 )
                                        .attr( "title", "Show All Items" )
                                        .insertAfter( input )
                                                input.autocomplete( "search", "" );
                                                input.focus();
                                        });
+                       },
+
+                       destroy: function() {
+                               this.input.remove();
+                               this.button.remove();
+                               this.element.show();
+                               $.Widget.prototype.destroy.call( this );
                        }
                });
        })( jQuery );