Storage.prototype.setObj = function(key, obj) {
return this.setItem(key, JSON.stringify(obj))
^-----Error in this line: Uncaught TypeError: Accessing selectionDirection on an input element that cannot have a selection
}
var selected = jQuery('input:checkbox.mychkbox:checked').each(function() {
return this.id;
});
sessionStorage.setObj("savedCollSearch",selected);
I am using jQuery 1.7.2 and Chrome 22. This error shows up as Uncaught Exception in Firefox 16. Search in SO and Google does not help and I have no clue how to resolve this.
I am 100% sure jQuery is loaded properly.
This expression...
var selected = jQuery('input:checkbox.mychkbox:checked').each(function() {
return this.id;
});
... seems to be misused here: it'll return you a jQuery-wrapped collection of checked checkbox elements, which is probably not quite easy to stringify (because of circular references).
(as a sidenote, .each
will stop the iteration at the first element which doesn't have an id
, or have it set to an empty string, but that doesn't matter much here)
You probably wanted to use this instead:
var selected = jQuery('input:checkbox.mychkbox:checked').map(function() {
return this.id;
}).get();