diff --git a/app/assets/javascripts/outfits/edit.js b/app/assets/javascripts/outfits/edit.js index 9b999a5a..83c9c847 100644 --- a/app/assets/javascripts/outfits/edit.js +++ b/app/assets/javascripts/outfits/edit.js @@ -408,10 +408,12 @@ View.Hash = function (wardrobe) { wardrobe.search.bind('updateRequest', function (request) { if(request.offset != data.search_offset || request.query != data.search) { - changeQuery({ - search_offset: request.offset, - search: request.query - }); + if (typeof request.query === "string") { + changeQuery({ + search_offset: request.offset, + search: request.query + }); + } } }); } @@ -1179,21 +1181,15 @@ View.Search = function (wardrobe) { fit(); }); - function updateQuery(query) { - current_query = query || ''; - var human_query = typeof query === 'string' ? query : ''; - input_el.val(human_query); - no_results_span.text(human_query); - } - - wardrobe.search.bind('updateQuery', updateQuery); - wardrobe.search.bind('updateRequest', function (request) { last_request = request; error_el.hide('fast'); help_el.hide(); no_results_el.hide(); - updateQuery(request.query); + current_query = request.query || ''; + var human_query = typeof current_query === 'string' ? current_query : ''; + input_el.val(human_query); + no_results_span.text(human_query); clear_el.toggle(!!request.query); }); diff --git a/app/assets/javascripts/wardrobe.js b/app/assets/javascripts/wardrobe.js index c87187ba..9244c525 100644 --- a/app/assets/javascripts/wardrobe.js +++ b/app/assets/javascripts/wardrobe.js @@ -1330,8 +1330,11 @@ function Wardrobe() { this.request = {}; function itemsOnLoad(items, total_pages, page, query) { + if(query !== search.request.query) { + search.request.query = query; + search.events.trigger('updateRequest', search.request); + } search.events.trigger('updateItems', items); - search.events.trigger('updateQuery', query); search.events.trigger('updatePagination', page, total_pages); }