JQbunchmultiple.prototype = {
init: function () {
+ this.addItemTriggerTimeout;
this.inited = false;
var $this = this;
this.id = $(this.element).attr('id');
}, 10);
} else {
item.removeClass('collapsed');
+ $(document).trigger('cubist.bunchmultiple.openitem');
}
return false;
});
},
initItem: function (values) {
-
+ clearTimeout(this.addItemTriggerTimeout);
var $this = this;
var collapsed = true;
var isNew = false;
$(this).attr('data-bmid', $this.id);
});
- setTimeout(function () {
+ this.addItemTriggerTimeout = setTimeout(function () {
$this.setValues(item, values, false);
$(document).trigger('cubist.bunchmultiple.added');
$($this).trigger('change');
- }, 10);
+ }, 100);
},
setValues(item, values) {
$(document).on('cubist.bunchmultiple.added', function () {
initUntriggeredSelectFromArray($);
});
+ $(document).on('cubist.bunchmultiple.openitem', function () {
+ initUntriggeredSelectFromArray($);
+ });
initUntriggeredSelectFromArray($);
$(document).on('change', '.select2_from_array', function () {
}
function initUntriggeredSelectFromArray($) {
+ let j = 0;
+
// trigger select2 for each untriggered select2 box
- $('.select2_from_array:not(.select2-hidden-accessible)').each(function (i, obj) {
- if ($(obj).closest('.item.sample').length > 0) {
+ $('.select2_from_array:not(.select2-hidden-accessible):visible:not(.init)').each(function (i, obj) {
+ if ($(obj).closest('.item.sample,.item.collapsed').length > 0) {
return;
}
var options = {
}
}
$(obj).addClass('init').select2(options);
+ j++;
});
+ if (j > 0) {
+ console.log('initUntriggeredSelectFromArray', j);
+ }
showSelectedValue();
}
</script>