Skip to content

Commit

Permalink
check data before append html
Browse files Browse the repository at this point in the history
  • Loading branch information
crissanclick committed Oct 5, 2017
1 parent 154dd01 commit c17b3eb
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions app/code/Magento/Search/view/frontend/web/form-mini.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,17 @@ define([
$.getJSON(this.options.url, {
q: value
}, $.proxy(function (data) {
$.each(data, function (index, element) {
var html;
element.index = index;
html = template({
data: element
if (data.length) {
$.each(data, function (index, element) {
var html;

element.index = index;
html = template({
data: element
});
dropdown.append(html);
});
dropdown.append(html);
});

if (dropdown.has('li').length) {
this.responseList.indexList = this.autoComplete.html(dropdown)
.css(clonePosition)
.show()
Expand All @@ -322,7 +323,8 @@ define([
this.element.attr('aria-activedescendant', $(e.target).attr('id'));
}.bind(this))
.on('mouseout', function (e) {
if (!this._getLastElement() && this._getLastElement().hasClass(this.options.selectClass)) {
if (!this._getLastElement() &&
this._getLastElement().hasClass(this.options.selectClass)) {
$(e.target).removeClass(this.options.selectClass);
this._resetResponseList(false);
}
Expand Down

0 comments on commit c17b3eb

Please sign in to comment.