I’m trying to figure out how to make a pop-up menu using the jQuery UI menu widget.
After searching around, I finally found the following demo that does what I want:
http://view.jqueryui.com/menubar/demos/popup/popup-menu.html
However, I am having a little trouble understanding this demo. For example:
- What is making the menu hidden before any of the buttons are clicked?
- What is causing the menu to close when it’s open and I click somewhere else on the page?
Any help appreciated.
I believe this may be what you’re looking for. When you call
.menu(), lots of things are triggered in the_create()function (as Derek said), like setting class names etc. Then, at lines 123-135 injquery.ui.menu.js, this happens:The second part makes sure all menus are collapsed when the user clicks on the page (
this.document) outside a menu (.ui-menu):this.collapseAll()is called, which callsthis._close(), which in turn callshide(). This should answer your second question.As for your first question, The first thing the
refresh()function does is:This finds all submenus not previously initialized (in this case all of them since we’re coming from
_create()) and initializes them, which includes hiding them.