Search not working anywhere else than the Header

Viewed 122

I seem to be having some issue regarding moving the search bar anywhere else than its original .twig file. I have moved the code needed to load it in but whenever you search you for one cannot press enter on search and it will not allow me to search any of the existing items.

Code added to menu.php

$data['search'] = $this->load->controller('common/search');
1 Answers

This is JavaScript (jQuery) issue.

Open /catalog/view/javascript/common.js

Find

$('#search input[name=\'search\']').on('keydown', function(e) {
  if (e.keyCode == 13) {
    $('header #search input[name=\'search\']').parent().find('button').trigger('click');
  }
});

Replace with

$('#search input[name=\'search\']').on('keydown', function(e) {
  if (e.keyCode == 13) {
    $('#search input[name=\'search\']').parent().find('button').trigger('click');
  }
});

I just removed header from jQuery selector. In your browser press Crtl + F5 (Chrome or FF) to reload the page with cache cleaning. Should work.

Related