[jQuery] Re: Click off a div and have it disappear

2008-11-24 Thread Liam Potter


if you just want it to be similar to a mouseoff then bind a mouseleave 
function to the li rather then using mouseoff.


shogunmike wrote:

Hi guys,

Since this is my first post I thought I'd introduce myself - I'm Mike,
working on a web startup in London. We're using jQuery (because it's
awesome!) for all of our JS needs.

However, I'm having a bit of a problem with creating a clickable menu.
In
particular, I'm trying to open a menu pane by clicking on a graphic (a
button). After the button graphic is clicked, it is replaced and then
an
additional div is added below which contains a ul element, with the
child li
elements. I want the menu to stay open indefinitely until somebody
clicks
anywhere on the screen except the menu, at which point the menu div
hides
and the picture will revert to it's original form.

I originally tried using $('*') select syntax and the mouseoff event,
but it
never seemed to work (it wouldn't allow me to click on the li elements
WITHIN the menu). If you want an example of what I'm trying to do (and
you have a Friendfeed account), then their more menu for each bit of
activity has exactly this behaviour. I haven't been able to find any
other examples that are similar - sorry!

If anybody is still a bit confused about what I'm trying to achieve,
then I'll gladly elaborate.

Thanks in advance for any help you can provide,

Mike.
  




[jQuery] Re: Click off a div and have it disappear

2008-11-24 Thread shogunmike

Thanks for the swift reply Liam!

If I select all of the li's, then bind a mouseleave function to each
of them, is it possible to combine this with a mousedown event to
close the menu once it's clicked outside of the div containing the ul/
li's?

Regards,

Mike.

On Nov 24, 5:33 pm, Liam Potter [EMAIL PROTECTED] wrote:
 if you just want it to be similar to a mouseoff then bind a mouseleave
 function to the li rather then using mouseoff.

 shogunmike wrote:
  Hi guys,

  Since this is my first post I thought I'd introduce myself - I'm Mike,
  working on a web startup in London. We're using jQuery (because it's
  awesome!) for all of our JS needs.

  However, I'm having a bit of a problem with creating a clickable menu.
  In
  particular, I'm trying to open a menu pane by clicking on a graphic (a
  button). After the button graphic is clicked, it is replaced and then
  an
  additional div is added below which contains a ul element, with the
  child li
  elements. I want the menu to stay open indefinitely until somebody
  clicks
  anywhere on the screen except the menu, at which point the menu div
  hides
  and the picture will revert to it's original form.

  I originally tried using $('*') select syntax and the mouseoff event,
  but it
  never seemed to work (it wouldn't allow me to click on the li elements
  WITHIN the menu). If you want an example of what I'm trying to do (and
  you have a Friendfeed account), then their more menu for each bit of
  activity has exactly this behaviour. I haven't been able to find any
  other examples that are similar - sorry!

  If anybody is still a bit confused about what I'm trying to achieve,
  then I'll gladly elaborate.

  Thanks in advance for any help you can provide,

  Mike.