mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Autocomplete: Respect the disabled option. Fixes #5619 - Autocomplete widget keeps looking for remote data even when it's disabled.
This commit is contained in:
parent
58ae7ce2fd
commit
90caa93a9b
@ -116,6 +116,24 @@ test("delay", function() {
|
|||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("disabled", function() {
|
||||||
|
var ac = $("#autocomplete").autocomplete({
|
||||||
|
source: data,
|
||||||
|
delay: 0,
|
||||||
|
disabled: true
|
||||||
|
});
|
||||||
|
ac.val("ja").keydown();
|
||||||
|
|
||||||
|
same( $(".ui-menu:visible").length, 0 );
|
||||||
|
|
||||||
|
stop();
|
||||||
|
setTimeout(function() {
|
||||||
|
same( $(".ui-menu:visible").length, 0 );
|
||||||
|
ac.autocomplete("destroy");
|
||||||
|
start();
|
||||||
|
}, 50);
|
||||||
|
});
|
||||||
|
|
||||||
test("minLength", function() {
|
test("minLength", function() {
|
||||||
var ac = $("#autocomplete").autocomplete({
|
var ac = $("#autocomplete").autocomplete({
|
||||||
source: data
|
source: data
|
||||||
|
12
ui/jquery.ui.autocomplete.js
vendored
12
ui/jquery.ui.autocomplete.js
vendored
@ -39,6 +39,10 @@ $.widget( "ui.autocomplete", {
|
|||||||
"aria-haspopup": "true"
|
"aria-haspopup": "true"
|
||||||
})
|
})
|
||||||
.bind( "keydown.autocomplete", function( event ) {
|
.bind( "keydown.autocomplete", function( event ) {
|
||||||
|
if ( self.options.disabled ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var keyCode = $.ui.keyCode;
|
var keyCode = $.ui.keyCode;
|
||||||
switch( event.keyCode ) {
|
switch( event.keyCode ) {
|
||||||
case keyCode.PAGE_UP:
|
case keyCode.PAGE_UP:
|
||||||
@ -88,10 +92,18 @@ $.widget( "ui.autocomplete", {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.bind( "focus.autocomplete", function() {
|
.bind( "focus.autocomplete", function() {
|
||||||
|
if ( self.options.disabled ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
self.selectedItem = null;
|
self.selectedItem = null;
|
||||||
self.previous = self.element.val();
|
self.previous = self.element.val();
|
||||||
})
|
})
|
||||||
.bind( "blur.autocomplete", function( event ) {
|
.bind( "blur.autocomplete", function( event ) {
|
||||||
|
if ( self.options.disabled ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
clearTimeout( self.searching );
|
clearTimeout( self.searching );
|
||||||
// clicks on the menu (or a button to trigger a search) will cause a blur event
|
// clicks on the menu (or a button to trigger a search) will cause a blur event
|
||||||
self.closing = setTimeout(function() {
|
self.closing = setTimeout(function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user