aboutsummaryrefslogtreecommitdiffstats
path: root/www/js/views/submit.js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-03-04 16:43:57 +0000
committerStruan Donald <struan@exo.org.uk>2013-03-04 16:56:28 +0000
commit1fd6b411e5f27c874aeabfcaf60b796be62049a3 (patch)
treea26aa2541a47ff0c60ab81f53f04198a825a7e20 /www/js/views/submit.js
parent7c160f9607dfbb05110720cb7b529fe6bfe9175c (diff)
Add and remove report sync events only once in the view
Diffstat (limited to 'www/js/views/submit.js')
-rw-r--r--www/js/views/submit.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/www/js/views/submit.js b/www/js/views/submit.js
index 7d8644d..1ce411e 100644
--- a/www/js/views/submit.js
+++ b/www/js/views/submit.js
@@ -15,6 +15,11 @@
'click #submit_register': 'onClickSubmit'
},
+ initialize: function() {
+ this.model.on('sync', this.onReportSync, this );
+ this.model.on('error', this.onReportError, this );
+ },
+
render: function(){
if ( !this.template ) {
console.log('no template to render');
@@ -33,9 +38,6 @@
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();
},
@@ -45,6 +47,11 @@
onReportError: function(model, err, options) {
alert( FMS.strings.sync_error + ': ' + err.errors);
+ },
+
+ _destroy: function() {
+ this.model.off('sync');
+ this.model.off('error');
}
})
});