У меня есть скрипт js, который помогает мне создать cookie. Сохраняет отмеченные флажки, поэтому это значение запоминается (устанавливается в cookie). Теперь проблема в том, что он не работает с переключателями. Читая js-файл, я вижу, что input type = checkboxes. Поэтому логично, что игнорируются переключатели.
Как изменить этот скрипт, чтобы он проверял не только отмеченные флажки, но и проверенные переключатели?
Большое спасибо
Мой js файл-скрипт:
jQuery(document).ready(function(){
new chkRemembrance();
});
function chkRemembrance(){
this.__construct();
}
chkRemembrance.prototype = {
__construct : function(){
this.chk = this.fetchData(); // initialise array to store the checkboxes
this.init();
},
init : function(){
// first initialise all checkboxes that are checked
for(c in this.chk){
$("input[type=checkbox]#" + c).attr('checked', this.chk[c]);
}
// now make sure we fetch the checkbox events
var o = this;
$("input[type=checkbox]").change(function(){
o.saveData(this.id, this.checked);
})
},
fetchData : function(){
var r = {};
if ($.cookie('chk')){
r = JSON.parse($.cookie('chk'));
}
return r;
},
saveData : function(id,status){
this.chk[id] = status;
$.cookie('chk', JSON.stringify(this.chk));
}
}