a4217d8fcc calls tokenize2() before it seems to be inititalized, lets check for content before calling clear.
This commit is contained in:
Ad Schellevis 2019-10-10 20:54:55 +02:00
parent 89918fc1de
commit 7a5a2712cd

View File

@ -135,13 +135,13 @@ function setFormData(parent,data) {
// data node found, handle per type
if (targetNode.is("select")) {
// handle select boxes
targetNode.empty(); // flush
if (targetNode.hasClass("tokenize")) {
if (targetNode.find('option').length > 0 && targetNode.hasClass("tokenize")) {
// when setting the same content twice to a widget, tokenize2 sorting mixes up.
// Ideally formatTokenizersUI() or tokenize2 should handle this better, but for now
// this seems like the only fix that actually works.
targetNode.tokenize2().trigger('tokenize:clear');
}
targetNode.empty(); // flush
$.each(node[keypart],function(indxItem, keyItem){
var opt = $("<option>").val(htmlDecode(indxItem)).text(keyItem["value"]);
if (keyItem["selected"] != "0") {