aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-03-25 10:09:43 +0000
committerStruan Donald <struan@exo.org.uk>2013-03-25 10:09:43 +0000
commit3b19639ee2f8d539ad1b42a0b04b07b230463624 (patch)
treeded0bad15f0367a1b3f7d11fa617952b17f806cd /www/js
parentf3f9d6ceede0ddd07be7fbfc03aa0e7839fafe36 (diff)
use listenTo instead of on for search event listening and also stop listening to events
Diffstat (limited to 'www/js')
-rw-r--r--www/js/views/search.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/www/js/views/search.js b/www/js/views/search.js
index 6f26e02..330f896 100644
--- a/www/js/views/search.js
+++ b/www/js/views/search.js
@@ -13,15 +13,15 @@
search: function() {
var pc = this.$('#pc').val();
- FMS.locator.on('search_located', this.searchSuccess, this );
- FMS.locator.on('search_failed', this.searchFail, this );
+ this.listenTo(FMS.locator, 'search_located', this.searchSuccess );
+ this.listenTo(FMS.locator, 'search_failed', this.searchFail);
$('#ajaxOverlay').show();
FMS.locator.lookup(pc);
},
-
searchSuccess: function( info ) {
+ this.stopListening(FMS.locator);
var coords = info.coordinates;
FMS.currentLocation = coords;
this.navigate('around');
@@ -37,6 +37,7 @@
},
searchFail: function( details ) {
+ this.stopListening(FMS.locator);
$('#ajaxOverlay').hide();
if ( details.msg ) {
this.displayError( details.msg );
@@ -51,6 +52,10 @@
} else {
this.displayError( FMS.strings.location_problem );
}
+ },
+
+ destroy: function() {
+ this.stopListening(FMS.locator);
}
})
});