diff options
author | Struan Donald <struan@exo.org.uk> | 2013-04-08 17:11:57 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-04-08 18:55:37 +0100 |
commit | a19459b65a8dbbc3ee12fbf7852956a1b322e3e6 (patch) | |
tree | 51f3a9cf8365e9d74fab63a8acc09fe078598048 /www/js/views/submit.js | |
parent | bd3a482f3c268c6f4e31c4be0e9b2b8d6045b680 (diff) |
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
Diffstat (limited to 'www/js/views/submit.js')
-rw-r--r-- | www/js/views/submit.js | 12 |
1 files changed, 6 insertions, 6 deletions
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' ); }, |