JQbunchmultiple.prototype = {
init: function () {
+ this.inited = false;
var $this = this;
this.id = $(this.element).attr('id');
this.bmidselector = '[data-bmid="' + this.id + '"]';
var initValues = this.element.data('values');
-
if (initValues.length === 0) {
this.initItem();
} else {
$.each(initValues, function (k, v) {
- $this.initItem(v);
+ $this.initItem(v, true);
});
}
return false;
});
- this.initSort();
-
this.element.on('change', 'input' + this.bmidselector +
',select' + this.bmidselector +
',textarea' + this.bmidselector +
return true;
});
+ this.initSort();
+
if ($(this.element).parent().closest('.bunchmultiple').length === 0) {
$(this.element).find('.bunchmultiple__wrapper:eq(0)').addClass('bunchmultiple_root');
$(this.element).addClass('bunchmultiple_root');
}
+
+ setTimeout(function () {
+ $this.inited = true;
+ $this.updateAndChange();
+ }, 1000);
},
cleanTemplate: function () {
},
update: function () {
+ if (!this.inited) {
+ return;
+ }
this.serialize();
this.updateLegends();
},
},
updateAndChange: function () {
+ if (!this.inited) {
+ return;
+ }
this.update();
$(this.element).trigger('change');
},
$(this.element).find(".bunchmultiple__items" + this.bmidselector).append($(item));
this.setValues(item, values);
-
$.each(nested, function (k, v) {
if (isNew) {
$('#' + v).find('.item:not(.sample)').remove();
});
setTimeout(function () {
- $this.setValues(item, values);
+ $this.setValues(item, values, false);
$(document).trigger('cubist.bunchmultiple.added');
$($this).trigger('change');
}, 500);