Skip to content

Commit

Permalink
fixed bug in search error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
triceam committed Oct 9, 2012
1 parent cc91358 commit 1b934b2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
4 changes: 3 additions & 1 deletion client/www/app/model/SearchManager.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

window.SearchManager = {

apiUrl:"http://localhost:3000/api?",
//apiUrl:"http://localhost:3000/api?",
apiUrl:"http://walkable.aws.af.cm/restaurants-api?",

search:function (searchString, successCallback, errorCallback) {
var searchURL = this.apiUrl + "q=" + encodeURIComponent(searchString) + "&ll=" + window.GeoWatcher.position.latitude + "," + window.GeoWatcher.position.longitude + "&d=" + new Date().getTime();

$.ajax({
timeout:10000,
url:searchURL,
success:function(result){
if ( successCallback ) {
Expand Down
29 changes: 16 additions & 13 deletions client/www/app/views/SearchView.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,38 @@ window.SearchView = Backbone.View.extend({
},

searchResult: function(result) {
//console.log(result);

try {
var jsonResult = JSON.parse(result);
var jsonResult = JSON.parse(result);

var self = this;
var self = this;

//cleanup once removed from view
setTimeout(function(){
self.$el.empty();
}, 550 );
//cleanup once removed from view
setTimeout(function(){
self.$el.empty();
}, 550 );

var view = new SearchResultsView({ model:jsonResult, searchString:this.searchString });
window.viewNavigator.replaceView( view );
var view = new SearchResultsView({ model:jsonResult, searchString:this.searchString });
window.viewNavigator.replaceView( view );
}
catch(e){
alert(e.toString())
}
},

searchError: function(error) {
//console.log(error);
// console.log(error);

var self = this;

//cleanup once removed from view
//wait for transition to finish, then cleanup once removed from view
setTimeout(function(){
self.$el.empty();
}, 500 );

var view = new SearchResultsView({ model:{points:[], polygons:[]}, searchString:this.searchString });
window.viewNavigator.replaceView( view );
var view = new SearchResultsView({ model:{points:[], polygons:[]}, searchString:this.searchString });
window.viewNavigator.replaceView( view );
}, 550 );
}


Expand Down

0 comments on commit 1b934b2

Please sign in to comment.