0

I have a form with the panel, which will have some checkboxes for options. I made panel slide in to the form when mouse hovers the edge of it (edge of panel). I made it hide (slide back) when mouse leaves the panel. The problem is that when I point a checkbox in this panel a mouseleave event occures and panel slides back so I cannot check checkbox. Is there any way to prevent mouseleave event when mouse is still over the panel and some checkboxes in it? My idea for know is to make a condition based on mouse pointer position in mouseleave event, but I hope that there is a way to make app treat a checkbox as a part of panel. Did not put any food since it is not problem of it. But can post if needed.

Łukasz Motyczka
  • 1,169
  • 2
  • 13
  • 35

1 Answers1

1

What happens here is that the mouseleave event of the checkbox triggers mouseleave event of the panel due to the event bubbling. You can read more about event bubbling here.

To prevent the event bubbling, attach mouseleave event on the checkboxes and call event.stopPropagation(). Sample code with jQuery:

$("checkboxes_selector").on("mouseleave", function(event){
    event.stopPropagation();
});
Community
  • 1
  • 1
Ilija Dimov
  • 5,221
  • 7
  • 35
  • 42