views:

384

answers:

3
A: 
- $("label.legend, label.childless").click( function(event){
+ $("label, input").click( function(event){

... and then some cosmetics to keep radio labels at place.

Andrejs Cainikovs
Thanks, Andrejs. It's cool solution. But in this case attribute toggleClass of label and next fieldset.subtype has no effect. It will obvious if we'll add new design rule to .expanded class (for example .expanded { display: block !important; background: #FCC}.
Vladimir
+1  A: 

Use the focus event on the radio button instead. Try this:

<script type="text/javascript">
    $(function(){ 
     accordionOptions();
    });
    var accordionOptions = function(){
     $("label.legend > input, label.childless > input").focus(function(event) {
      var el = $(this).parent();
      var opposites = $(".subtype").not(el.next());
      opposites.find("input:checked").attr("checked", false);
      opposites.removeClass("expanded");
      el.siblings("label").removeClass("expanded");
      el.next(".subtype").toggleClass("expanded");
      el.toggleClass("expanded");
     });
    }
</script>
Jason Berry
Thanks, Jason. I repeat reoly for previous solution. It's cool. But in this case attribute toggleClass of label and next fieldset.subtype has no effect. It will obvious if we'll add new design rule to .expanded class (for example .expanded { display: block !important; background: #FCC}.
Vladimir
A: 

This works in my end:

$("label.legend, label.childless").click( function(event){
  var opposites = $(".subtype").not($(this).next());
  var el = $(this);
  opposites.find("input:checked").removeAttr('checked');
  opposites.removeClass("expanded");
  el.siblings("label").removeClass("expanded");
  el.next(".subtype").addClass("expanded");
  el.toggleClass("expanded");
});

That being exchanging toggleClass for addClass.

Eivind