We assembled a jQuery UI button and menu widgets to give us a drop-down menu, see this fiddle for a demo and the full code.
For the HTML you need a button and a nested list, such as:
<button>Please choose...</button>
<ul class="accounts">
<li> <a href="#">Bank</a>
<ul>
<li><a href="#">Lloyds</a>
</li>
<li><a href="#">Barclays</a>
</li>
</ul>
</li>
<li><a href="#">Cash</a>
</li>
</ul>
The CoffeeScript sets up a menu (hidden initially) and the button to toggle the menu:
select_account_button = $('button')
accounts_menu = $('.accounts')
# turn the button into a dropdown that shows/hides the menu
select_account_button.button
icons:
secondary: "ui-icon-triangle-1-s"
.click ->
accounts_menu.show().position(
my: "left top"
at: "left bottom"
of: this
)
$(document).one "click", ->
accounts_menu.hide()
false
# set up the menu (hidden initially)
accounts_menu.hide()
.menu
select: (event, ui) ->
console.log "selected"