From b4c21901a5ff11403a126a1cc24e84d4d4d27dfd Mon Sep 17 00:00:00 2001 From: Levi Jackson Date: Fri, 3 Apr 2015 10:06:28 -0400 Subject: [PATCH 1/2] allow for multiple checkboxes with the same name but different values --- source/javascripts/jquery.remember-state.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/javascripts/jquery.remember-state.js b/source/javascripts/jquery.remember-state.js index 684ea67..bd698fd 100644 --- a/source/javascripts/jquery.remember-state.js +++ b/source/javascripts/jquery.remember-state.js @@ -46,11 +46,15 @@ $e; for (var i in data) { $e = $f.find("[name=\"" + data[i].name + "\"]"); + if ($e.is(":radio")) { $e.filter("[value=\"" + data[i].value + "\"]").prop("checked", true); } else if ($e.is(":checkbox") && data[i].value) { - $e.prop("checked", true); + $e = $f.find("[name=\"" + data[i].name + "\"][value=\"" + data[i].value + "\"]"); + if ($e.length) { + $e.prop("checked", true); + } } else if ($e.is("select")) { $e.find("[value=\"" + data[i].value + "\"]").prop("selected", true); From 89f8afe745c4e097784f188f2537eafbbeb5d0cb Mon Sep 17 00:00:00 2001 From: Levi Jackson Date: Fri, 3 Apr 2015 10:18:21 -0400 Subject: [PATCH 2/2] change find to filter --- source/javascripts/jquery.remember-state.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/javascripts/jquery.remember-state.js b/source/javascripts/jquery.remember-state.js index bd698fd..ba7444e 100644 --- a/source/javascripts/jquery.remember-state.js +++ b/source/javascripts/jquery.remember-state.js @@ -51,7 +51,7 @@ $e.filter("[value=\"" + data[i].value + "\"]").prop("checked", true); } else if ($e.is(":checkbox") && data[i].value) { - $e = $f.find("[name=\"" + data[i].name + "\"][value=\"" + data[i].value + "\"]"); + $e = $e.filter("[value=\"" + data[i].value + "\"]"); if ($e.length) { $e.prop("checked", true); }