@@ -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
@@ -848,7 +842,8 @@ define([
848
842
deleteRecord : function ( index , recordId ) {
849
843
var recordInstance ,
850
844
lastRecord ,
851
- recordsData ;
845
+ recordsData ,
846
+ lastRecordIndex ;
852
847
853
848
if ( this . deleteProperty ) {
854
849
recordsData = this . recordData ( ) ;
@@ -867,12 +862,13 @@ define([
867
862
this . update = true ;
868
863
869
864
if ( ~ ~ this . currentPage ( ) === this . pages ( ) ) {
865
+ lastRecordIndex = ( this . startIndex + this . getChildItems ( ) . length - 1 ) ;
870
866
lastRecord =
871
867
_ . findWhere ( this . elems ( ) , {
872
- index : this . startIndex + this . getChildItems ( ) . length - 1
868
+ index : lastRecordIndex
873
869
} ) ||
874
870
_ . findWhere ( this . elems ( ) , {
875
- index : ( this . startIndex + this . getChildItems ( ) . length - 1 ) . toString ( )
871
+ index : lastRecordIndex . toString ( )
876
872
} ) ;
877
873
878
874
lastRecord . destroy ( ) ;
@@ -1133,6 +1129,18 @@ define([
1133
1129
} ) ;
1134
1130
1135
1131
this . isDifferedFromDefault ( ! _ . isEqual ( recordData , this . default ) ) ;
1132
+ } ,
1133
+
1134
+ /**
1135
+ * Set the changed property if the current page is different
1136
+ * than the default state
1137
+ *
1138
+ * @return void
1139
+ */
1140
+ setChangedForCurrentPage : function ( ) {
1141
+ this . pagesChanged [ this . currentPage ( ) ] =
1142
+ ! compareArrays ( this . defaultPagesState [ this . currentPage ( ) ] , this . arrayFilter ( this . getChildItems ( ) ) ) ;
1143
+ this . changed ( _ . some ( this . pagesChanged ) ) ;
1136
1144
}
1137
1145
} ) ;
1138
1146
} ) ;
0 commit comments