diff options
Diffstat (limited to 'www/js/views/submit.js')
-rw-r--r-- | www/js/views/submit.js | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/www/js/views/submit.js b/www/js/views/submit.js index 3a04621..7d8644d 100644 --- a/www/js/views/submit.js +++ b/www/js/views/submit.js @@ -3,7 +3,49 @@ SubmitView: FMS.FMSView.extend({ template: 'submit', id: 'submit-page', - prev: 'details' + prev: 'details', + + events: { + 'pagehide': 'destroy', + 'pageshow': 'afterDisplay', + 'click .ui-btn-left': 'onClickButtonPrev', + 'click .ui-btn-right': 'onClickButtonNext', + 'click #submit_signed_in': 'onClickSubmit', + 'click #submit_sign_in': 'onClickSubmit', + 'click #submit_register': 'onClickSubmit' + }, + + render: function(){ + if ( !this.template ) { + console.log('no template to render'); + return; + } + template = _.template( tpl.get( this.template ) ); + if ( this.model ) { + this.$el.html(template({ model: this.model.toJSON(), user: FMS.currentUser })); + } else { + this.$el.html(template()); + } + this.afterRender(); + return this; + }, + + onClickSubmit: function(e) { + this.model.set( 'submit_clicked', $(e.target).attr('id') ); + + this.model.on('sync', this.onReportSync, this ); + this.model.on('error', this.onReportError, this ); + + this.model.save(); + }, + + onReportSync: function(model, resp, options) { + this.navigate( 'sent', 'left' ); + }, + + onReportError: function(model, err, options) { + alert( FMS.strings.sync_error + ': ' + err.errors); + } }) }); })(FMS, Backbone, _, $); |