diff --git a/src/assets/yii2-dynamic-form.js b/src/assets/yii2-dynamic-form.js index fbe3045..9b44799 100644 --- a/src/assets/yii2-dynamic-form.js +++ b/src/assets/yii2-dynamic-form.js @@ -81,7 +81,7 @@ } else if($(this).is('select')) { $(this).find('option:selected').removeAttr("selected"); } else { - $(this).val(''); + $(this).val(''); } }); @@ -199,7 +199,7 @@ matches[2] = matches[2].substring(1, matches[2].length - 1); var identifiers = matches[2].split('-'); identifiers[0] = index; - + if (identifiers.length > 1) { var widgetsOptions = []; $elem.parents('div[data-dynamicform]').each(function(i){ @@ -225,7 +225,7 @@ $(this).removeClass('field-' + id).addClass('field-' + newID); }); // update "for" attribute - $elem.closest(widgetOptions.widgetItem).find("label[for='" + id + "']").attr('for',newID); + $elem.closest(widgetOptions.widgetItem).find("label[for='" + id + "']").attr('for',newID); } return newID; @@ -455,12 +455,14 @@ _restoreKrajeeDepdrop($(this)); } - $.when($('#' + id).select2(configSelect2)).done(initSelect2Loading(id, '.select2-container--krajee')); + var s2LoadingFunc = typeof initSelect2Loading != 'undefined' ? initSelect2Loading : initS2Loading; + var s2OpenFunc = typeof initSelect2DropStyle != 'undefined' ? initSelect2Loading : initS2Loading; + $.when($('#' + id).select2(configSelect2)).done(s2LoadingFunc(id, '.select2-container--krajee')); var kvClose = 'kv_close_' + id.replace(/\-/g, '_'); $('#' + id).on('select2:opening', function(ev) { - initSelect2DropStyle(id, kvClose, ev); + s2OpenFunc(id, kvClose, ev); }); $('#' + id).on('select2:unselect', function() {