I have an application where I need a structure like this:

  <a href="#">
    <input type="checkbox" name="foo" />
    Some label here.
  </a>

The reason for the anchor is that I want MSIE 6 to support "hovering"
behavior for styling purposes.

What I want to have happen is that when the user clicks anywhere on
the anchor, the checkbox is toggled, and have the browser *not* add
the "#" to the end of the page URL.  I'm connecting a function like
this:

  function click_anchor(evt) {
    // Select the checkbox even when clicking on just the surrounding anchor.
    var input = evt.src().getElementsByTagName("input").item(0);
    var target = evt.target();
    if (!input.isSameNode(target)) {
      input.checked = !input.checked;
      logDebug("toggling");
    }
    evt.stop();
    return false;
  }

to the anchor element's onclick:

  connect(anchor, "onclick", click_anchor)

What I can't seem to achieve is to toggle the checkbox when clicked
directly (rather than somewhere else in the anchor) without having the
"#" added to the URL.  So far I'm only testing on Firefox 2.0.0.3, but
if I can't even get this working there, MSIE is going to be hopeless.

I'm sure I'm missing something obvious; can anyone here point me in
the right direction?


  -Fred

-- 
Fred L. Drake, Jr.    <fdrake at gmail.com>
"Chaos is the score upon which reality is written." --Henry Miller

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to