Button that opens a dropdown list when clicked. More akin to a popup menu than a combobox. Compared to a simple <select> element:
set up for any custom UI in the list.
TODO: merge DropdownEventHandler into this? Are there any other widgets that might want to use it separately?
Creates a single dropdown-button instance. The DOM node is created but not attached to the document anywhere - clients should append this.$button to the appropriate location.
DropdownButton dispatches the following events:
function DropdownButton(label, items, itemRenderer) {
this.items = items;
this.itemRenderer = itemRenderer || this.itemRenderer;
this._onClick = this._onClick.bind(this);
this.closeDropdown = this.closeDropdown.bind(this);
this._onClickOutside = this._onClickOutside.bind(this);
this.$button = $("<button class='btn btn-dropdown'/>")
.text(label)
.on("click", this._onClick);
}
EventDispatcher.makeEventDispatcher(DropdownButton.prototype);