6

I have a page that is doing a continuous ajax refresh, and I don't want to do this refresh if the user is currently making a selection in a dropdown. Is there any way to check if the user has the dropdown opened, and then stop the update?

Thanks!

Shane Fulmer
  • 7,510
  • 6
  • 35
  • 43

2 Answers2

1

The only way I can think of, is to use a flag (a variable) that will change value when the user clicks the SELECT (and knowing that when the page is first loaded, the SELECT is closed) this should make it easy to know if the SELECT is open or not.

Soufiane Hassou
  • 17,257
  • 2
  • 39
  • 75
  • How would you determine when it was closed again? – Shane Fulmer Nov 06 '09 at 21:14
  • hmm, sorry, I totally missed the case when SELECT is closed by clicking elsewhere. Did you try focus events for the SELECT ? – Soufiane Hassou Nov 06 '09 at 21:30
  • I tried using the focus/blur combination, but it doesn't seem to accurately capture when the dropdown is closed. If you open the select, then close it by clicking elsewhere, it doesn't fire the blur event. – Shane Fulmer Nov 06 '09 at 21:33
  • 1
    What if you tab through and use arrows? – Peter Ajtai Sep 07 '12 at 21:31
  • 1
    What if you expand the select using + ? – Haroldo_OK Jun 18 '13 at 14:37
  • 1
    Alt+DownArrow doesn't open the dropdown in Safari under Windows. It does in most other browsers though. As does Alt+UpArrow. The spacebar also opens the dropdown in Opera and Chrome, but not in most others. In Firefox, you can also press and hold the mouse button and drag to the item you want (just like using the menu bar). This will generate a single onclick, but the dropdown will be closed afterwards. Most other browsers don't do that. – Mr Lister Feb 10 '14 at 14:25
0

Try binding "click" to the body whenever the select is clicked. That event will fire whenever the user clicks off the select.

eli
  • 187
  • 2
  • 15