11/**
22 * jQuery.ddMM.mm_ddMultipleFields
3- * @version 2.5.7 (2021-01-15 )
3+ * @version 2.5.9 (2021-10-04 )
44 *
55 * @uses jQuery 1.9.1
66 * @uses jQuery.ddTools 1.8.1
77 * @uses jQuery.ddMM 1.1.2
88 *
9- * @copyright 2013–2020 [DD Group]{@link https://DivanDesign.biz }
9+ * @copyright 2013–2021 [DD Group]{@link https://DivanDesign.biz }
1010 */
1111
1212( function ( $ ) {
@@ -189,7 +189,7 @@ $.ddMM.mm_ddMultipleFields = {
189189
190190 /**
191191 * @method init
192- * @version 4.3.4 (2021-01-15 )
192+ * @version 4.3.5 (2021-10-04 )
193193 *
194194 * @desc Инициализация.
195195 *
@@ -236,9 +236,6 @@ $.ddMM.mm_ddMultipleFields = {
236236 if ( columnObject . type == 'id' ) {
237237 columnIdIndex = columnIndex ;
238238
239- //Remove deprecated column
240- delete instance . columns [ columnIndex ] ;
241-
242239 //Continue
243240 return true ;
244241 }
@@ -257,7 +254,11 @@ $.ddMM.mm_ddMultipleFields = {
257254
258255 //Prepare width
259256 if ( ! columnObject . width ) {
260- if ( columnIndex > 0 ) {
257+ if (
258+ //Preverious column exist
259+ $ . isPlainObject ( instance . columns [ columnIndex - 1 ] ) &&
260+ instance . columns [ columnIndex - 1 ] . width
261+ ) {
261262 //Take from preverious column
262263 instance . columns [ columnIndex ] . width = instance . columns [ columnIndex - 1 ] . width ;
263264 } else {
@@ -273,6 +274,15 @@ $.ddMM.mm_ddMultipleFields = {
273274 }
274275 ) ;
275276
277+ //If deprecated ID column exists
278+ if ( columnIdIndex != - 1 ) {
279+ //Remove it
280+ instance . columns . splice (
281+ columnIdIndex ,
282+ 1
283+ ) ;
284+ }
285+
276286 var
277287 //Объект значения поля
278288 fieldValueObject = _this . init_prepareFieldValueObject ( {
@@ -359,7 +369,7 @@ $.ddMM.mm_ddMultipleFields = {
359369
360370 /**
361371 * @method init_prepareFieldValueObject
362- * @version 1.0.2 (2020-05-25 )
372+ * @version 1.1 (2021-10-04 )
363373 *
364374 * @desc Инициализация → Подготовка объекта значений поля.
365375 *
@@ -390,7 +400,11 @@ $.ddMM.mm_ddMultipleFields = {
390400 ) ==
391401 '{'
392402 ) {
393- fieldValueObject = $ . parseJSON ( params . value ) ;
403+ try {
404+ fieldValueObject = $ . parseJSON ( params . value ) ;
405+ } catch {
406+ fieldValueObject = { } ;
407+ }
394408 //Bacward compatibility
395409 } else {
396410 var
@@ -411,8 +425,12 @@ $.ddMM.mm_ddMultipleFields = {
411425 rowId = _this . generateRowId ( )
412426 ;
413427
414- //If deprecated ID column exists
415- if ( params . columnIdIndex != - 1 ) {
428+ if (
429+ //If deprecated ID column exists
430+ params . columnIdIndex != - 1 &&
431+ //And not empty
432+ columnValuesArray [ params . columnIdIndex ] != ''
433+ ) {
416434 rowId = columnValuesArray [ params . columnIdIndex ] ;
417435 }
418436
0 commit comments