I like the jQuery DatePicker widget. It is very user friendly that when the user clicks on a date field in my web application, the user sees a dialog that allows her to select a date.
What's even better is the way the datepicker is so unobtrusive. If the user doesn't want to use the datepicker, she can easily type a date on her own. Furthermore, the datepicker automagically disappears when the user clicks on anything that isn't the datepicker or shifts the focus to another field.
What I would like to do is have the same functionality with the jQuery dialog. Basically, I want to create a dialog with some widgets that the user can use to select a value for a text field.
I want the dialog to automatically appear underneath the text field when the field is selected. I want it to automatically disappear after the user shifts the focus somewhere else.
In order to accomplish this, I've attached a handler to the text field .focus
event in jQuery to make the dialog appear. That works fine. :-)
I've tried adding a handler to the .blur
event to make the dialog automatically close when the user goes somewhere else. However, merely opening the dialog causes the blur
event to fire, closing it :-/
Furthermore, I don't know of any way to make the dialog appear directly underneath the text field the same way that the datepicker does.
How can I make a jQuery dialog appear next to a text field and disappear appropriately like the datepicker?