Toggle executes twice

Toggle executes twice

Hi all,

Brand new to JQuery and having a hard time with it. I inherited a project that involves a submission form. The form has categories for users to select from, many of which have sub-categories that are hidden on page load.

The form is designed so that when a checkbox is clicked, the corresponding subcategories appear. It has worked fine, to date.

Here is the code from our .js file that I think makes this happen:

   $('#category-list input').click( function(event) {
      if ( ! $(this).attr('checked') ) {
         $(this).next('ul').find('input:checked').attr('checked','');
      }
      $(this).next('ul').slideToggle();
   });


I modified another part of the form that performs a search on our site for related content and displays the results in a div further up the page. Now, whenever you load the form, if you don't search in this area the categories work fine, but if you search, then play with categories, they behave oddly.

For instance, if you click a parent category, the subcategories appear then immediately disappear again, as if the toggle happens twice. Once in a while it "bounces" open and closed three or four times, all from one click!

Does this sound familiar to anyone? Have I described the problem well enough? Thanks so much for any ideas and your patience with this newbie.

Cheers,
jabc