mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Autocomplete demo: Combobox cleanup.
This commit is contained in:
parent
ca88fc1f65
commit
f0c203a9a0
@ -24,7 +24,7 @@
|
|||||||
bottom: 0;
|
bottom: 0;
|
||||||
margin-left: -1px;
|
margin-left: -1px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
/* adjust styles for IE 6/7 */
|
/* support: IE7 */
|
||||||
*height: 1.7em;
|
*height: 1.7em;
|
||||||
*top: 0.1em;
|
*top: 0.1em;
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@
|
|||||||
.addClass( "ui-combobox" )
|
.addClass( "ui-combobox" )
|
||||||
.insertAfter( select );
|
.insertAfter( select );
|
||||||
|
|
||||||
function removeIfInvalid(element) {
|
function removeIfInvalid( element ) {
|
||||||
var value = $( element ).val(),
|
var value = $( element ).val(),
|
||||||
matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( value ) + "$", "i" ),
|
matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( value ) + "$", "i" ),
|
||||||
valid = false;
|
valid = false;
|
||||||
@ -56,6 +56,7 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if ( !valid ) {
|
if ( !valid ) {
|
||||||
// remove invalid value, as it didn't match anything
|
// remove invalid value, as it didn't match anything
|
||||||
$( element )
|
$( element )
|
||||||
@ -66,8 +67,7 @@
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
input.tooltip( "close" ).attr( "title", "" );
|
input.tooltip( "close" ).attr( "title", "" );
|
||||||
}, 2500 );
|
}, 2500 );
|
||||||
input.data( "autocomplete" ).term = "";
|
input.data( "ui-autocomplete" ).term = "";
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,13 +103,14 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
change: function( event, ui ) {
|
change: function( event, ui ) {
|
||||||
if ( !ui.item )
|
if ( !ui.item ) {
|
||||||
return removeIfInvalid( this );
|
removeIfInvalid( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.addClass( "ui-widget ui-widget-content ui-corner-left" );
|
.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>" )
|
return $( "<li>" )
|
||||||
.append( "<a>" + item.label + "</a>" )
|
.append( "<a>" + item.label + "</a>" )
|
||||||
.appendTo( ul );
|
.appendTo( ul );
|
||||||
@ -144,19 +145,14 @@
|
|||||||
input.focus();
|
input.focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
input
|
input.tooltip({
|
||||||
.tooltip({
|
tooltipClass: "ui-state-highlight"
|
||||||
position: {
|
});
|
||||||
of: this.button
|
|
||||||
},
|
|
||||||
tooltipClass: "ui-state-highlight"
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function() {
|
_destroy: function() {
|
||||||
this.wrapper.remove();
|
this.wrapper.remove();
|
||||||
this.element.show();
|
this.element.show();
|
||||||
$.Widget.prototype.destroy.call( this );
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})( jQuery );
|
})( jQuery );
|
||||||
|
Loading…
Reference in New Issue
Block a user