From 90522c0f5099368d7a914f646e675a38cef46046 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 24 Aug 2015 16:29:28 +0900 Subject: [PATCH] Handle null return value from request --- static/scripts/search.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/static/scripts/search.js b/static/scripts/search.js index afcec25..0a1dd4c 100644 --- a/static/scripts/search.js +++ b/static/scripts/search.js @@ -141,6 +141,8 @@ } function outputSnapshot(results, omitValues) { + var records = results.records || []; + _ctx.query.minScore = results.minScore; $('#minScore').val(results.minScore); @@ -153,8 +155,8 @@ _ctx.grapher.setColumns(columns); - var searchResultCnt = String(results.records.length); - if (results.records.length < results.count) { + var searchResultCnt = String(records.length); + if (records.length < results.count) { searchResultCnt += ' of ' + results.count; } $('#resultCount').text(searchResultCnt); @@ -162,7 +164,7 @@ var template = Handlebars.compile($('#template').html()); $('#records').empty(); - $('#records').append(template({records: results.records})); + $('#records').append(template({records: records})); $('span.sort-icon').css('visibility', 'hidden'); var currentColumn = $('span.sort-icon[data-sort="' + _ctx.sortKey + '"]').css('visibility', 'visible'); @@ -173,7 +175,7 @@ currentColumn.removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down'); } - if (results.records.length === 0) { + if (records.length === 0) { $('#resultPanel').slideUp(); } else {