Skip to content

Commit

Permalink
Refs #20302; take into consideration that the option tag could no lon…
Browse files Browse the repository at this point in the history
…ger be present within the select tag and if so then add it with the value saved from the form
  • Loading branch information
ichim-david committed Aug 20, 2014
1 parent e4c7bc0 commit 1f8b8cc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions eea/jquery/plugins/remember_state/jquery.remember-state.js
Expand Up @@ -46,15 +46,21 @@
restoreState: function(e) {
var data = JSON.parse(localStorage.getItem(this.objName)),
$f = this.$el,
$e;
$e, $select_option;
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);
} else if ($e.is("select")) {
$e.find("[value=\"" + data[i].value + "\"]").prop("selected", true);
$select_option = $e.find("[value=\"" + data[i].value + "\"]");
if ($select_option.length) {
$select_option.prop("selected", true);
}
else {
$("<option>", {value: data[i].value, selected: true}).text(data[i].value).appendTo($e);
}
} else {
$e.val(data[i].value);
}
Expand Down

0 comments on commit 1f8b8cc

Please sign in to comment.