[ 2 posts ]

Jacob Fogg

YUI Contributor

  • Username: jacobfogg
  • Joined: Fri Oct 09, 2009 11:15 am
  • Posts: 24
  • Location: Denver, CO
  • Twitter: jacobfogg
  • GitHub: jacobfogg
  • Gists: jacobfogg
  • IRC: jfogg
  • Offline
  • Profile
Tags:

Problems with adding a checkbox to the head

Post Posted: Thu Oct 06, 2011 1:01 pm
+0-
Hey there, we have a use case where we want to attach a check mark next to the title of the accordion widget head. We are accomplishing that no problem. Where we do have a problem is actually checking the checkbox. The click event of the checkbox is bubbling up to another event listener and stealing the checkbox's click.

I have added a delegate click listener to the item's contentBox, and using e.stopImmediatePropagation() I can prevent the the item from expanding AND get the check box checked... this however allows the anchor to execute it's default behavior, and since the anchors all have an href of #, it pops the browser to the top of the page.

I was able to further hack the situation by giving the anchor an href of #+theIdOfTheAnchor, which is a bit better, but still causes the browser to pop around the page with every checkbox click... super annoying!

I am thinking that perhaps I am listening to the wrong event, or maybe using the wrong method for stopping the propagation (I have tried just e.stopPropagation(), but I cannot get the the checkbox to take on the check).


Thanks!

Iliyan Peychev

YUI Contributor

  • Username: peychevi
  • Joined: Tue Feb 24, 2009 12:38 pm
  • Posts: 136
  • Location: Varna, Bulgaria
  • Twitter: ipeychev
  • GitHub: ipeychev
  • Gists: ipeychev
  • Offline
  • Profile

Re: Problems with adding a checkbox to the head

Post Posted: Thu Oct 06, 2011 8:34 pm
+0-
Hello,

Can you please try with preventDefault instead stopPropagation?

If it does not work, please create an example and I will take a look.

Iliyan
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum