Moving initialize up to the top.

This commit is contained in:
George Stephanis 2015-08-13 13:01:42 -04:00
parent 0ac1aab79c
commit 6dddc2ad84
1 changed files with 13 additions and 13 deletions

View File

@ -66,6 +66,19 @@
rowTemplate : rowTemplate, rowTemplate : rowTemplate,
per_page : data.limit, per_page : data.limit,
page : data.page, page : data.page,
initialize : function() {
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 );
// this.listenTo( this.model, 'saved:rates', this.clearUnloadConfirmation );
$tbody.on( 'change', { view : this }, this.updateModelOnChange );
$tbody.on( 'sortupdate', { view : this }, this.updateModelOnSort );
$search_field.on( 'keyup search', { view : this }, this.onSearchField );
$pagination.on( 'click', 'a', { view : this }, this.onPageChange );
$pagination.on( 'change', 'input', { view : this }, this.onPageChange );
$(window).on( 'beforeunload', { view : this }, this.unloadConfirmation );
},
render : function() { render : function() {
var rates = this.model.getFilteredRates(), var rates = this.model.getFilteredRates(),
qty_rates = _.size( rates ), qty_rates = _.size( rates ),
@ -138,19 +151,6 @@
window.history.replaceState( {}, '', url ); window.history.replaceState( {}, '', url );
}, },
initialize : function() {
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 );
// this.listenTo( this.model, 'saved:rates', this.clearUnloadConfirmation );
$tbody.on( 'change', { view : this }, this.updateModelOnChange );
$tbody.on( 'sortupdate', { view : this }, this.updateModelOnSort );
$search_field.on( 'keyup search', { view : this }, this.onSearchField );
$pagination.on( 'click', 'a', { view : this }, this.onPageChange );
$pagination.on( 'change', 'input', { view : this }, this.onPageChange );
$(window).on( 'beforeunload', { view : this }, this.unloadConfirmation );
},
onSearchField : function( event ){ onSearchField : function( event ){
event.data.view.updateUrl(); event.data.view.updateUrl();
event.data.view.render(); event.data.view.render();