jquery.combobox: Added 'showButton' option

This commit is contained in:
Thomas Tanghus 2012-04-29 20:28:50 +02:00
parent c7e7767f58
commit 163344243b
1 changed files with 33 additions and 30 deletions

View File

@ -4,6 +4,12 @@
(function( $ ) {
$.widget('ui.combobox', {
options: {
id: null,
name: null,
showButton: false,
editable: true
},
_create: function() {
//console.log('_create: ' + this.options['id']);
var self = this,
@ -71,8 +77,12 @@
.append( "<a>" + item.label + "</a>" )
.appendTo( ul );
};
$.each(this.options, function(key, value) {
self._setOption(key, value);
});
/*this.button = $( "<button type='button'>&nbsp;</button>" )
if(this.options['showButton']) {
this.button = $( "<button type='button'>&nbsp;</button>" )
.attr( "tabIndex", -1 )
.attr( "title", "Show All Items" )
.insertAfter( input )
@ -92,11 +102,8 @@
// pass empty string as value to search for, displaying all results
input.autocomplete( "search", "" );
input.focus();
});*/
this.options['editable'] = true;
$.each(this.options, function(key, value) {
self._setOption(key, value);
});
}
},
destroy: function() {
this.input.remove();
@ -135,18 +142,14 @@
});
break;
case 'editable':
this.options['editable'] = value;
case 'showButton':
this.options[key] = value;
break;
}
// In jQuery UI 1.8, you have to manually invoke the _setOption method from the base widget
$.Widget.prototype._setOption.apply( this, arguments );
// In jQuery UI 1.9 and above, you use the _super method instead
//this._super( "_setOption", key, value );
},
options: {
id: null,
name: null,
editable: true
},
}
});
})( jQuery );