module( "autocomplete: core" );
+test( "markup structure", function( assert ) {
+ expect( 2 );
+ var element = $( "#autocomplete" ).autocomplete(),
+ menu = element.autocomplete( "widget" );
+
+ assert.hasClasses( element, "ui-autocomplete-input" );
+ assert.hasClasses( menu, "ui-autocomplete ui-widget ui-widget-content" );
+});
+
test( "prevent form submit on enter when menu is active", function() {
expect( 2 );
var event,
options: {
appendTo: null,
autoFocus: false,
+ classes: {},
delay: 300,
minLength: 1,
position: {
this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
this.isNewMenu = true;
- this.element
- .addClass( "ui-autocomplete-input" )
- .attr( "autocomplete", "off" );
+ this._addClass( "ui-autocomplete-input" );
+ this.element.attr( "autocomplete", "off" );
this._on( this.element, {
keydown: function( event ) {
this._initSource();
this.menu = $( "<ul>" )
- .addClass( "ui-autocomplete ui-front" )
.appendTo( this._appendTo() )
.menu({
// disable ARIA support, the live region takes care of that
.hide()
.menu( "instance" );
+ this._addClass( this.menu.element, "ui-autocomplete", "ui-front" );
this._on( this.menu.element, {
mousedown: function( event ) {
// prevent moving focus out of the text field
"aria-live": "assertive",
"aria-relevant": "additions"
})
- .addClass( "ui-helper-hidden-accessible" )
.appendTo( this.document[ 0 ].body );
+ this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
+
// turning off autocomplete prevents the browser from remembering the
// value when navigating through history, so we re-enable autocomplete
// if the page is unloaded before the widget is destroyed. #7790
_destroy: function() {
clearTimeout( this.searching );
- this.element
- .removeClass( "ui-autocomplete-input" )
- .removeAttr( "autocomplete" );
+ this.element.removeAttr( "autocomplete" );
this.menu.element.remove();
this.liveRegion.remove();
},
_search: function( value ) {
this.pending++;
- this.element.addClass( "ui-autocomplete-loading" );
+ this._addClass( "ui-autocomplete-loading" );
this.cancelSearch = false;
this.source( { term: value }, this._response() );
this.pending--;
if ( !this.pending ) {
- this.element.removeClass( "ui-autocomplete-loading" );
+ this._removeClass( "ui-autocomplete-loading" );
}
}, this );
},