This repository was archived by the owner on Apr 2, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,3 +25,4 @@ John Moses <moses.john.r@gmail.com>
2525Ian Lim <mallim.ink@gmail.com>
2626David Burrows <david@imergent.com>
2727Anthony Wu <wu@learnsprout.com>
28+ Marc Neuwirth <marc.neuwirth@gmail.com>
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ var Body = Backgrid.Body = Backbone.View.extend({
6767 emptyText : this . emptyText ,
6868 columns : this . columns
6969 } ) ) ;
70+ return true ;
7071 }
7172 } ,
7273
@@ -154,7 +155,9 @@ var Body = Backgrid.Body = Backbone.View.extend({
154155 // removeRow() is called directly
155156 if ( ! options ) {
156157 this . collection . remove ( model , ( options = collection ) ) ;
157- this . _unshiftEmptyRowMayBe ( ) ;
158+ if ( this . _unshiftEmptyRowMayBe ( ) ) {
159+ this . render ( ) ;
160+ }
158161 return ;
159162 }
160163
@@ -163,7 +166,9 @@ var Body = Backgrid.Body = Backbone.View.extend({
163166 }
164167
165168 this . rows . splice ( options . index , 1 ) ;
166- this . _unshiftEmptyRowMayBe ( ) ;
169+ if ( this . _unshiftEmptyRowMayBe ( ) ) {
170+ this . render ( ) ;
171+ }
167172
168173 return this ;
169174 } ,
Original file line number Diff line number Diff line change @@ -247,6 +247,29 @@ describe("A Body", function () {
247247 expect ( body . $el . find ( "tr.empty" ) . length ) . toBe ( 0 ) ;
248248 } ) ;
249249
250+ it ( "will show the empty row if all rows are removed from the collection" , function ( ) {
251+ col . reset ( { id : 4 } ) ;
252+ body = new Backgrid . Body ( {
253+ emptyText : " " ,
254+ columns : [ {
255+ name : "id" ,
256+ cell : "integer"
257+ } ] ,
258+ collection : col
259+ } ) ;
260+ body . render ( ) ;
261+ expect ( body . $el . find ( "tr.empty" ) . length ) . toBe ( 0 ) ;
262+
263+ col . remove ( col . at ( 0 ) ) ;
264+ expect ( body . $el . find ( "tr.empty" ) . length ) . toBe ( 1 ) ;
265+
266+ body . insertRow ( { id : 5 } ) ;
267+ expect ( body . $el . find ( "tr.empty" ) . length ) . toBe ( 0 ) ;
268+
269+ body . removeRow ( col . at ( 0 ) ) ;
270+ expect ( body . $el . find ( "tr.empty" ) . length ) . toBe ( 1 ) ;
271+ } ) ;
272+
250273 it ( "#sort will throw a RangeError is direction is not ascending, descending or null" , function ( ) {
251274 body = new Backgrid . Body ( {
252275 collection : col ,
You can’t perform that action at this time.
0 commit comments