]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete demo: Combobox cleanup.
authorScott González <scott.gonzalez@gmail.com>
Mon, 26 Nov 2012 21:13:21 +0000 (16:13 -0500)
committerScott González <scott.gonzalez@gmail.com>
Mon, 26 Nov 2012 21:13:21 +0000 (16:13 -0500)
demos/autocomplete/combobox.html

index 9fd5d4050dd7161ecca00d4ec1539dbcfbc93c9e..6229d47b2167b9e2170e317519a6981c18d780cc 100644 (file)
@@ -24,7 +24,7 @@
                bottom: 0;
                margin-left: -1px;
                padding: 0;
-               /* adjust styles for IE 6/7 */
+               /* support: IE7 */
                *height: 1.7em;
                *top: 0.1em;
        }
@@ -46,7 +46,7 @@
                                                .addClass( "ui-combobox" )
                                                .insertAfter( select );
 
-                               function removeIfInvalid(element) {
+                               function removeIfInvalid( element ) {
                                        var value = $( element ).val(),
                                                matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( value ) + "$", "i" ),
                                                valid = false;
@@ -56,6 +56,7 @@
                                                        return false;
                                                }
                                        });
+
                                        if ( !valid ) {
                                                // remove invalid value, as it didn't match anything
                                                $( element )
@@ -66,8 +67,7 @@
                                                setTimeout(function() {
                                                        input.tooltip( "close" ).attr( "title", "" );
                                                }, 2500 );
-                                               input.data( "autocomplete" ).term = "";
-                                               return false;
+                                               input.data( "ui-autocomplete" ).term = "";
                                        }
                                }
 
                                                        });
                                                },
                                                change: function( event, ui ) {
-                                                       if ( !ui.item )
-                                                               return removeIfInvalid( this );
+                                                       if ( !ui.item ) {
+                                                               removeIfInvalid( this );
+                                                       }
                                                }
                                        })
                                        .addClass( "ui-widget ui-widget-content ui-corner-left" );
 
-                               input.data( "autocomplete" )._renderItem = function( ul, item ) {
+                               input.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
                                        return $( "<li>" )
                                                .append( "<a>" + item.label + "</a>" )
                                                .appendTo( ul );
                                                input.focus();
                                        });
 
-                                       input
-                                               .tooltip({
-                                                       position: {
-                                                               of: this.button
-                                                       },
-                                                       tooltipClass: "ui-state-highlight"
-                                               });
+                               input.tooltip({
+                                       tooltipClass: "ui-state-highlight"
+                               });
                        },
 
-                       destroy: function() {
+                       _destroy: function() {
                                this.wrapper.remove();
                                this.element.show();
-                               $.Widget.prototype.destroy.call( this );
                        }
                });
        })( jQuery );