From a19459b65a8dbbc3ee12fbf7852956a1b322e3e6 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Mon, 8 Apr 2013 17:11:57 +0100 Subject: Trying to use the same model for both remote and localStorage was involving all sorts of hackery so it's easier and cleaner to move to separate models for reports and drafts --- www/js/views/submit.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'www/js/views/submit.js') diff --git a/www/js/views/submit.js b/www/js/views/submit.js index 8faf32b..b48461c 100644 --- a/www/js/views/submit.js +++ b/www/js/views/submit.js @@ -15,11 +15,6 @@ 'click #submit_register': 'onClickSubmit' }, - initialize: function() { - this.listenTo(this.model, 'sync', this.onReportSync ); - this.listenTo( this.model, 'error', this.onReportError ); - }, - render: function(){ if ( !this.template ) { console.log('no template to render'); @@ -40,7 +35,10 @@ if ( this.validate() ) { this.model.set('user', FMS.currentUser); - this.model.save(); + this.report = new FMS.Report( this.model.toJSON() ); + this.listenTo( this.report, 'sync', this.onReportSync ); + this.listenTo( this.report, 'error', this.onReportError ); + this.report.save(); } }, @@ -48,6 +46,8 @@ if ( FMS.currentUser ) { FMS.currentUser.save(); } + FMS.currentDraft = new FMS.Draft(); + FMS.createdReport = this.report; this.navigate( 'sent', 'left' ); }, -- cgit v1.2.3