fnagel/jquery-ui — Issue #177: Document click doesn't always close open menus
Author: thg2k
Created: 2011-10-14 03:47:12+00:00
State: open

I noticed that if you have many select menus in the page, and you destroy and recreate one of them, the other ones won't close after click.
The reason why is because you bind to document the click event and then unbind all of them in destroy method.

I fixed this in the following way BUT there is a much more elegant fix, if you check in textbox they bind a global "widget level" event to the document, I think selectmenu should do the same, bind only once globally and then close any open menu at click time, so this way if you have 10 widgets you don't bind 10 times to the document click.

// document click closes menu
$(document).bind("mousedown.selectmenu", function(event) {
self.close(event);
self._closeOthers(event);
});