Skip to content

Commit 6a76c39

Browse files
cloneData select2 plugin initilize issue fixed.
1 parent 7e6dc6c commit 6a76c39

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

cloneData.js

+20-4
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393

9494
// stop append HTML if maximum limit exceed
9595
if (settings.maxLimit != 0 && item_exists >= settings.maxLimit){
96-
alert('You cannot exceed more then '+ settings.maxLimit +' item(s).');
96+
alert("More than "+ settings.maxLimit +" degrees can\'t be added in one form. Please 'Add New'.");
9797
return false;
9898
}
9999

@@ -235,6 +235,12 @@
235235
$(this).remove();
236236
});
237237

238+
if($template.find('.select2-container').length > 0){
239+
$template.find('.select2-container').each(function(){
240+
$(this).remove();
241+
});
242+
}
243+
238244
$template.find('.select2-container').remove();
239245

240246
//Remove Elements with excludeHTML
@@ -261,9 +267,17 @@
261267

262268
var _initializePlugins = function(){
263269
/* Initialize again chosen dropdown after render HTML */
264-
$('.chosen-init').each(function(){
265-
$(this).chosen().trigger('chosen:update');
266-
});
270+
if($('.chosen-init').length >0){
271+
$('.chosen-init').each(function(){
272+
$(this).chosen().trigger('chosen:update');
273+
});
274+
}
275+
276+
if($('.select2').length >0){
277+
$('.select2').each(function(){
278+
$(this).select2({ width: '100%' }).trigger('select2:update');
279+
});
280+
}
267281

268282
if($.fn.datepicker && $('.datepicker-init').length > 0) {
269283
$('.datepicker-init').datepicker({autoclose: true});
@@ -313,6 +327,7 @@
313327
$elem.parents('.' + settings.cloneContainer).slideUp(function(){
314328
$(this).remove();
315329
_updateAttributes();
330+
settings.afterRemove.call(this);
316331
//_initializePlugins();
317332
});
318333
}
@@ -328,6 +343,7 @@
328343

329344

330345
$(document).on('click', '.' + settings.removeButtonClass, function(){
346+
settings.beforeRemove.call(this);
331347
_deleteItem($(this));
332348
});
333349

0 commit comments

Comments
 (0)