1

I am using Drupal 6 and, therefore, jQuery 1.2.6.

When a user clicks inside my text, there is a pop-up that comes up with a few more options in it. I would like this pop up to disappear when the focus is moved to anywhere outside. This answer on SO comes very close but the focusout event isn't available to me in jQuery 1.2.6.

Has anyone else encountered this issue? How did you work around it?
I would rather not use the jquery update module, as I don't own the site and don't want to be responsible if the update breaks something else.

1
  • 1
    Not sure this question really belongs on Drupal Answers as it's not a Drupal question.
    – Camsoft
    Mar 23 '11 at 10:23
1

Add a .mouseleave() event to the popup div

Taking the example code from the SO question you mentioned, see the working version at http://jsfiddle.net/Laxman13/Mw8VD/6/

4
  • Interestingly, your example works great in IE but not in FireFox! I think you are on the right track though.
    – Icode4food
    Mar 22 '11 at 1:14
  • @Icode4food try the jsfiddle link now. It works on my end for IE, FF and Chrome
    – Laxman13
    Mar 22 '11 at 1:54
  • If I embed another div inside that div it will call the parent div's mouseout event when going into the child. Any suggestions how to work around this? I'm obviously not a js guru, I try to stick with backend PHP stuff but every now and then I get stuck with a ui project. :)
    – Icode4food
    Mar 22 '11 at 11:57
  • @Icode4food updated the jsfiddle link again. Removing mouseout and only using mouseleave works with a child element.
    – Laxman13
    Mar 22 '11 at 13:42
0

you could try the blur() function.

from the jquery docs

The blur event is sent to an element when it loses focus. Originally, this event was only applicable to form elements, such as . In recent browsers, the domain of the event has been extended to include all element types. An element can lose focus via keyboard commands, such as the Tab key, or by mouse clicks elsewhere on the page. Blockquote

http://api.jquery.com/blur/

-2

Will it work as expected with jQuery 1.3.2, because you can install the jQuery_update module. I normally upgrade jQuery on all drupal 6 sites that I work with due to most jquery plugins etc have compatibility with 1.3.x

1
  • OP mentioned not wanting to use jquery_update in question
    – Laxman13
    Mar 22 '11 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.