【问题标题】:Jquery cookies issue with multiple buttonsets多个按钮集的 Jquery cookie 问题
【发布时间】:2015-07-12 03:42:51
【问题描述】:

根据这个问题,我问并回答了自己...... setting jquery cookies for buttonset 我可以为单个按钮组设置 cookie,但现在我正在尝试为多个按钮组做同样的事情。我让它工作的唯一我不知道的是如何选择和刷新按钮集......具有讽刺意味的是,这是我在第一个问题时遇到的问题,但我想出了如何做到这一点,没有这样的运气时间。

$(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});    
    });
  });
});

【问题讨论】:

    标签: javascript jquery cookies jqueryi-ui-buttonset


    【解决方案1】:

    好吧,我又想通了……

    这是工作代码...

    $(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});
            });
        });
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多