redacademy / it-winter-2018

2 stars 2 forks source link

Search: Does not submit upon hitting enter #10

Closed rcass closed 6 years ago

rcass commented 6 years ago

The search in the nav bar does not submit when you hit enter.

2lives commented 6 years ago

var $searchInput = $('.search-field'); $('.main-navigation .search-field').on('click', function (e) { e.preventDefault(); $searchInput.focus();

$(document).on('keypress', function (event) {
  if ($searchInput.val() !== '') {
    if (event.which == 13) {
      console.log('enter pressed');
      $('.search-form').submit();
    }
  }
});

});

this seems to do the trick!

rcass commented 6 years ago

Looks like it is functioning now 👍