0

I have the following inside of my Header Template of an Ajax Accordion:

   <ajaxToolkit:Accordion runat="server" ID="accQuestions" TransitionDuration="250" FramesPerSecond="30" HeaderCssClass="moduleheader" HeaderSelectedCssClass="moduleheader selected" RequireOpenedPane="false">
  <HeaderTemplate>
     <div class="image" title="Expand/collapse">
        <a class="heading_link" href="<%#GetQuestionUrl((Answer)Container.DataItem) %>" >Question Header</a>
     </div>
  </HeaderTemplate>

And the following Javascript that assigns a click event to all of the anchors:

   $("a.heading_link").click(function() {
      $(this).parent().click();
      return false;
   });

I need this to work without JS as well, which is why I still generate the HREF on the links, so I'm just intercepting the click and then invoking the parent click which in turn toggles the accordion header.

This works in IE but no Firefox, Chrome.

Mantorok
  • 5,168
  • 2
  • 24
  • 32

1 Answers1

0

Did you try this?

$("a.heading_link").click(function(e) {
      e.preventDefault();
      $(this).parent().click();
   });
Capsule
  • 6,118
  • 1
  • 20
  • 27
  • Ah, preventDefault works, but I had to remove the parent.click and it's all working - thanks! – Mantorok Feb 04 '11 at 12:23
  • Which makes sense because of the natural propagation of events (see http://api.jquery.com/event.stopPropagation/ to avoid it, just in case you need this one day ;-)) – Capsule Feb 09 '11 at 14:25