1

I'm currently studding jqueryui datepicker, and I can't understand, how it prevents onblur effect on an input.

That is: when You click on an input with datepicker, the calendar appears, and You can click on next/prev month, but an input stays focused. You also may click anywhere within calendar and it does not disappear. But when You click any other link outside calendar and input, calendar disappears and link works, that means there doesn't exist any transparent div over a page that holds onclick event (for closing calendar).

It seems there is something like onblur event that is binded to an input. But this event doesn't trigger when You click within calendar. How do they do that?

A similar question was discussed here, but in jquery datepicker there is no timeouts.

Community
  • 1
  • 1
Kasheftin
  • 7,509
  • 11
  • 41
  • 68
  • My suggestion would be to download the un-minified version and take a look at what is going on under the hood. – bmoran Jan 23 '12 at 19:56

1 Answers1

1

So that's how it works in jqueryui datepicker. There's an input and an onfocus event to show calendar div. And there's no onblur event. Instead of this there is onmousedown event, attached to the whole document. There we check event.target and its parents for matching to our calendar div class and input.

Kasheftin
  • 7,509
  • 11
  • 41
  • 68