Skip to content

Commit

Permalink
Persist state of select elements before clonig them, fixes #91
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Dec 8, 2017
1 parent 4fe74f4 commit b0aa71a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Resources/public/js/be_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ var restoreSelectorScripts = function(element) {

}

var persistSelects = function(element) {

$(element).getElements('select').each(function(select) {

var option = select.getElement('option:selected') || select.getElement('option');
var oldOption = select.getElement('option[selected]');

if (oldOption) {
oldOption.removeAttribute('selected');
}

if (option) {
option.setAttribute('selected', '');
}

});

}

var updateListButtons = function(listElement) {

listElement = $(listElement);
Expand Down Expand Up @@ -408,6 +427,7 @@ var duplicateElement = function(linkElement) {

removeTinyMCEs(element);
restoreSelectorScripts(element);
persistSelects(element);

var newItem = element.cloneNode(true);

Expand Down

0 comments on commit b0aa71a

Please sign in to comment.