engineer9090909090909090 / jquery-datepicker

Automatically exported from code.google.com/p/jquery-datepicker
0 stars 0 forks source link

Advise: Is there a way to prevent focus on the text area in Firefox after date selection? #218

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I am new to jquery and datePicker, so this may be obvious to some, but was not 
so to me. If you look at the first sample in Firefox or Chrome 
(http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePicker.html),you
 find that after you select the date the focus is switched to the text input 
field. I am modifying some existing code using datePicker and one of the tasks 
is to have the focus switch to the next field immediately after the date has 
been selected.

I have attempted to use the code below:
.bind(
   'dateSelected',
   function()
   {
      document.getElementById("nextElement").focus();
   }
);

In internet explorer this code works as I would expect, but not in firefox or 
chrome. There may be a more correct way to do this. Could somebody please 
advise?

Thanks

Original issue reported on code.google.com by CFOgr...@gmail.com on 22 Jun 2010 at 4:58

GoogleCodeExporter commented 8 years ago
Attempted using .bind('dpClosed', ...)

Still no luck.

Original comment by CFOgr...@gmail.com on 22 Jun 2010 at 5:10

GoogleCodeExporter commented 8 years ago
Hmmmm - I'd expect it to work in the dpClosed handler... Does it work if you 
use jQuery to trigger the focus e.g

.bind(
   'dpClosed',
   function()
   {
      $("#nextElement").focus();
   }
);

Your point about it only working in IE is interesting. If you look in the 
sourcecode for the date picker you will see a section starting with "// TODO: 
Instead of this which doesn't work in IE" - I'm thinking that that block should 
probably be moved above the closeOnSelect block above as probably you are 
getting the dpClosed event and then the focus is being re-set in other 
browsers...

I'll have a quick play and see if I can find a better solution - it seems to me 
it should be easy to automatically focus the next element...

Original comment by kelvin.l...@gmail.com on 22 Jun 2010 at 5:49

GoogleCodeExporter commented 8 years ago
Fixed in r99 - grab the latest code and pass in {autoFocusNextInput: true} when 
you initialise the date picker - no need to focus it yourself....

Original comment by kelvin.l...@gmail.com on 22 Jun 2010 at 6:18

GoogleCodeExporter commented 8 years ago
Thank you for the fix. If I may recommend it though, an element identifier 
instead of true/false may be better. It allows for greater customization for 
the user.

Thanks again for the fix.

Original comment by CFOgr...@gmail.com on 22 Jun 2010 at 7:02