Problem! jQuery datePicker focus on input after select/close

Problem! jQuery datePicker focus on input after select/close

Hi, really need help with this... Hope anyone have some experience with this.

I want the calendar layer to close after click on a date or key press on return button AND sets the focus to the input field that I just clicked on.

I get it to work in FF but that is just because the browser handle like it does, can't get it to work in IE. IE handles like this; wherever I place the .focus() to set the focus back to the input it (handles like you could expect it to do) opens up aging after I clicked on a date or key press on return button.

This code example DON'T work but I hope it shows what I want to accomplish.

$(".datepicker").datepicker({
   numberOfMonths: 2,
   showButtonPanel: true,
   defaultDate: '-1m',
   minDate: '0m',
   maxDate: '+1y',
   onSelect: function(date) {
      $(this).focus();   
   },
   onClose: function(date) {
      $(".datepicker").datepicker("hide");
   }                  
});