javascriptjquerycookiesjqueryi-ui-buttonset

Jquery cookies issue with multiple buttonsets


As per this question I asked and answered myself... setting jquery cookies for buttonset I'm able to set cookies for individual buttonsets but now I'm trying to do the same for multiple buttonsets. I got it to work only thing I can't figure out is how to select and refresh the buttonsets... which ironically was the the problem I was having with my first question but I figured out how to do it, no such luck this time.

$(function(){ 
  var radioButtonSet=$('.setCookies').find('.setupRadioButtons');
  radioButtonSet.buttonset();
  var radio=$('.setupRadioButtons').find(':radio'), radioCookieName='selection';

  radio.each(function(){
    var selected=$.cookie(radioCookieName + '|' + this.name);
    $(this).prop('checked', true).button('refresh')  // CAN'T GET THIS TO WORK
    $(this).click(function() {
      $.cookie(radioCookieName + '|' + this.name, $(this).val(), {expires: 365});    
    });
  });
});

Solution

  • Well once again I figured it out...

    Here's the working code...

    $(function(){                                                                                       // Sets cookies for Check boxes
        var radioButtonSet=$('.setCookies').find('.radioButtons');
        radioButtonSet.buttonset();
        var radio=$('.radioButtons').find(':radio');
    
        radio.each(function(){
            var selected=$.cookie(this.name);
            $('#'+selected).prop('checked', true).button('refresh');
    
            $(this).click(function() {
                $.cookie(this.name, this.id, {expires: 365});
            });
        });
    });