Thanks for the tip Intrader.  Using changestart worked like a charm,
but I am a bit confused as to how I can obtain the menu item that was
clicked on in the accordion... here is the code:

$('.ui-accordion').bind('accordionchangestart', function(event,
target) {
    if (validateStep())
    {
      $("#accordion").accordion('activate', index);
    }

    event.stopPropogation();
});

My question now is how can I use this code to figure out which menu
item in the accordion was clicked on so I can determine which
accordion panel to display after validateStep function runs.
Essentially, for this part of the code:

$("#accordion").accordion('activate', index);

I am unclear on how to obtain the 'index' value to determine which
panel to display next.  Trying to get the target from the event
results in getting the #accordion div, which is not what I need, what
I need is the index of the menu item that was clicked on by the user -
any idea if it is possible to get that information from the event
object in this case?  Still new to Jquery so I'm not really sure how
else I can obtain this value.  Would really appreciate if you can
point me in the right direction.

Thanks!

On Nov 27, 5:46 am, intrader <[email protected]> wrote:
> Look into the changestart event
>
> On Nov 26, 1:35 am, Stinky Tofu <[email protected]> wrote:
>
>
>
> > I am writing a form wizard using JQuery's accordion module. The
> > problem is I want to override any mouse clicks on the accordion menu
> > so that the form is validated first before the accordion will show the
> > next section.
>
> > I have tried the following:
>
> > $('#accordion h3').unbind();
>
> > $('#accordion h3').click(function() {
> >   if (validate())
> >   {
> >     $("#accordion").accordion('activate', 2);
> >   }else
> >   {
> >     alert("invalid form");
> >   }}
>
> > But the above code doesn't work. The built-in click event of the
> > accordion still gets called and the accordion shows the next section
> > regardless of whether the form is valid or not.
>
> > I have also tried the following code:
>
> > $('#accordion h3').click(function(event) {
> >    if (validate())
> >    {
> >      $("#accordion").accordion('activate', 2);
> >    }else
> >    {
> >      alert("invalid form");
> >    }
> >    event.stopPropagation();
>
> > });
>
> > But the stopPropagation() call doesn't seem to affect the accordion
> > behaviour at all, the next section is displayed whether or not the
> > form is valid.
>
> > Any idea what I may be doing wrong?
>
> > Thanks!

--

You received this message because you are subscribed to the Google Groups 
"jQuery UI" 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/jquery-ui?hl=en.


Reply via email to