app/assets/javascripts/ckeditor/plugins/cells/dialogs/cells.js in nacelle-0.4.1 vs app/assets/javascripts/ckeditor/plugins/cells/dialogs/cells.js in nacelle-0.4.2
- old
+ new
@@ -76,10 +76,18 @@
if(element.name.endsWith("[]")) {
return values
} else {
return values[0]
}
+ break;
+ case 'select-multiple':
+ return Array.from(element.options)
+ .filter(o => o.selected)
+ .map(o => o.value)
+ .join(",")
+ break;
+
default:
return element.value
}
}
@@ -103,13 +111,17 @@
case 'checkbox':
element.checked = element.value === value;
break;
case 'select-multiple':
- var values = value.constructor === Array ? value : [value];
- for(var k = 0; k < element.options.length; k++) {
- element.options[k].selected = (values.indexOf(element.options[k].value) > -1 );
- }
+ var values = value.toString().split(",");
+ Array.from(element.options).forEach(option => {
+ if(values.includes(option.value)) {
+ option.setAttribute("selected", "selected")
+ } else {
+ option.removeAttribute("selected")
+ }
+ })
break;
case 'select':
case 'select-one':
element.value = value.toString() || value;