Let's do a simpler way of changing Object to array.

Underscore gives us lots of tools, it would be a shame not to use them.
This commit is contained in:
George Stephanis 2015-08-12 14:39:34 -04:00
parent 220550621a
commit 72c16a2472
1 changed files with 2 additions and 2 deletions

View File

@ -53,7 +53,7 @@
per_page : data.limit,
page : data.page,
render : function() {
var rates = $.map( this.model.getFilteredRates(), function(v){return [v]} ),
var rates = _.toArray( this.model.getFilteredRates() ),
qty_rates = rates.length,
qty_pages = Math.ceil( qty_rates / this.per_page ),
first_index = this.per_page * ( this.page - 1),
@ -114,7 +114,7 @@
window.history.replaceState( {}, '', url );
},
initialize : function() {
this.qty_pages = Math.ceil( $.map( this.model.get( 'rates' ), function(v){return [v]} ).length / this.per_page );
this.qty_pages = Math.ceil( _.toArray( this.model.get( 'rates' ) ).length / this.per_page );
this.page = this.sanitizePage( data.page );
this.listenTo( this.model, 'change:rates', this.setUnloadConfirmation );