2

This is issue can also be seen in the documentation, http://jqueryui.com/demos/autocomplete/#custom-data

I'm rendering custom menu which is identical to Facebook header search. When you right click on any item and then left click outside the menu, it stays open. Can I override this functionality to close the menu?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Daniyal
  • 241
  • 1
  • 4
  • 11

1 Answers1

0

You can use the following code to close the menu:

.autocomplete( "close" )

http://jqueryui.com/demos/autocomplete/#method-close

I assume you already knew that though, so the real question is how do you tie this close method to the blur event of some element on your ul or li.

You can override the ._renderMenu() method of the autocomplete box and add a .blur() event to the some element on your ul that way. I just posted an example of how to override this method here:

autocomplete ._renderItem and adding a Class to wrapper

Community
  • 1
  • 1
sngregory
  • 406
  • 2
  • 5