Skip to content

Commit 2fcdcd6

Browse files
author
Eugene Tupikov
committed
#286 avoid removal of all rows on the page when there are several widgets on the page and method clear was called
1 parent 1d00a0a commit 2fcdcd6

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/assets/src/js/jquery.multipleInput.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
(function ($) {
2+
'use strict';
3+
4+
String.prototype.replaceAll = function (search, replace) {
5+
return this.split(search).join(replace);
6+
};
7+
28
$.fn.multipleInput = function (method) {
39
if (methods[method]) {
410
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
@@ -68,41 +74,55 @@
6874
* the ID of widget
6975
*/
7076
id: null,
77+
7178
/**
7279
* the ID of related input in case of using widget for an active field
7380
*/
7481
inputId: null,
82+
7583
/**
7684
* the template of row
7785
*/
7886
template: null,
87+
7988
/**
8089
* array that collect js templates of widgets which uses in the columns
8190
*/
8291
jsTemplates: [],
92+
8393
/**
8494
* array of scripts which need to execute before initialization
8595
*/
8696
jsInit: [],
97+
8798
/**
8899
* how many row are allowed to render
89100
*/
90101
max: 1,
102+
91103
/**
92104
* a minimum number of rows
93105
*/
94106
min: 1,
107+
95108
/**
96109
* active form options of attributes
97110
*/
98111
attributes: {},
112+
99113
/**
100114
* default prefix of a widget's placeholder
101115
*/
102116
indexPlaceholder: 'multiple_index',
103117

118+
/**
119+
* whether need to show general error message or no
120+
*/
104121
showGeneralError: false,
105122

123+
/**
124+
* if need to prepend new row, not append
125+
*/
106126
prepend: false
107127
};
108128

@@ -221,7 +241,7 @@
221241
},
222242

223243
clear: function () {
224-
$('.js-input-remove').each(function () {
244+
$(this).find('.js-input-remove').each(function () {
225245
removeInput($(this));
226246
});
227247
},
@@ -466,8 +486,4 @@
466486
});
467487
return values;
468488
};
469-
470-
String.prototype.replaceAll = function (search, replace) {
471-
return this.split(search).join(replace);
472-
};
473489
})(window.jQuery);

src/assets/src/js/jquery.multipleInput.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)