@@ -330,9 +330,7 @@ define([
330
330
}
331
331
332
332
if ( this . defaultPagesState [ this . currentPage ( ) ] ) {
333
- this . pagesChanged [ this . currentPage ( ) ] =
334
- ! compareArrays ( this . defaultPagesState [ this . currentPage ( ) ] , this . arrayFilter ( this . getChildItems ( ) ) ) ;
335
- this . changed ( _ . some ( this . pagesChanged ) ) ;
333
+ this . setChangedForCurrentPage ( ) ;
336
334
}
337
335
} ,
338
336
@@ -442,13 +440,9 @@ define([
442
440
return initialize ;
443
441
} ) ) ;
444
442
445
- this . pagesChanged [ this . currentPage ( ) ] =
446
- ! compareArrays ( this . defaultPagesState [ this . currentPage ( ) ] , this . arrayFilter ( this . getChildItems ( ) ) ) ;
447
- this . changed ( _ . some ( this . pagesChanged ) ) ;
443
+ this . setChangedForCurrentPage ( ) ;
448
444
} else if ( this . hasInitialPagesState [ this . currentPage ( ) ] ) {
449
- this . pagesChanged [ this . currentPage ( ) ] =
450
- ! compareArrays ( this . defaultPagesState [ this . currentPage ( ) ] , this . arrayFilter ( this . getChildItems ( ) ) ) ;
451
- this . changed ( _ . some ( this . pagesChanged ) ) ;
445
+ this . setChangedForCurrentPage ( ) ;
452
446
}
453
447
} ,
454
448
@@ -849,7 +843,8 @@ define([
849
843
deleteRecord : function ( index , recordId ) {
850
844
var recordInstance ,
851
845
lastRecord ,
852
- recordsData ;
846
+ recordsData ,
847
+ lastRecordIndex ;
853
848
854
849
if ( this . deleteProperty ) {
855
850
recordsData = this . recordData ( ) ;
@@ -868,12 +863,13 @@ define([
868
863
this . update = true ;
869
864
870
865
if ( ~ ~ this . currentPage ( ) === this . pages ( ) ) {
866
+ lastRecordIndex = ( this . startIndex + this . getChildItems ( ) . length - 1 ) ;
871
867
lastRecord =
872
868
_ . findWhere ( this . elems ( ) , {
873
- index : this . startIndex + this . getChildItems ( ) . length - 1
869
+ index : lastRecordIndex
874
870
} ) ||
875
871
_ . findWhere ( this . elems ( ) , {
876
- index : ( this . startIndex + this . getChildItems ( ) . length - 1 ) . toString ( )
872
+ index : lastRecordIndex . toString ( )
877
873
} ) ;
878
874
879
875
lastRecord . destroy ( ) ;
@@ -1134,6 +1130,18 @@ define([
1134
1130
} ) ;
1135
1131
1136
1132
this . isDifferedFromDefault ( ! _ . isEqual ( recordData , this . default ) ) ;
1133
+ } ,
1134
+
1135
+ /**
1136
+ * Set the changed property if the current page is different
1137
+ * than the default state
1138
+ *
1139
+ * @return void
1140
+ */
1141
+ setChangedForCurrentPage : function ( ) {
1142
+ this . pagesChanged [ this . currentPage ( ) ] =
1143
+ ! compareArrays ( this . defaultPagesState [ this . currentPage ( ) ] , this . arrayFilter ( this . getChildItems ( ) ) ) ;
1144
+ this . changed ( _ . some ( this . pagesChanged ) ) ;
1137
1145
}
1138
1146
} ) ;
1139
1147
} ) ;
0 commit comments