Jquery 多个按钮集的 cookie 问题
Jquery cookies issue with multiple buttonsets
根据这个问题,我自己问并回答了...
setting jquery cookies for buttonset
我可以为单个按钮集设置 cookie,但现在我正在尝试为多个按钮集做同样的事情。我让它工作,唯一我无法弄清楚的是如何 select 和刷新按钮组......具有讽刺意味的是我在第一个问题中遇到的问题但我想出了如何去做,这次就没这么幸运了。
$(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});
});
});
});
好吧,我又一次想通了...
这是工作代码...
$(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});
});
});
});
根据这个问题,我自己问并回答了... setting jquery cookies for buttonset 我可以为单个按钮集设置 cookie,但现在我正在尝试为多个按钮集做同样的事情。我让它工作,唯一我无法弄清楚的是如何 select 和刷新按钮组......具有讽刺意味的是我在第一个问题中遇到的问题但我想出了如何去做,这次就没这么幸运了。
$(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});
});
});
});
好吧,我又一次想通了...
这是工作代码...
$(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});
});
});
});