Post by rowinzy » Sun Aug 13, 2017 5:37 am

I am having a hard time figuring this one out. So, I duplicated the default theme in order to create a custom one. I have moved the search box from the header to a new location and the search is not working at all. It is not getting the value for the search input field. How does the search box work?

Here is my 'search.twig' file:

Code: Select all

<div id="search">
  <input type="text" name="search" value="{{ search }}" placeholder="{{ text_search }}" />
  <button type="button" class="search-btn">{{ text_search }}</button>
</div>
Here is the 'javascript' code:

Code: Select all

$('#search input[name=\'search\']').parent().find('button').on('click', function() {
		var url = $('base').attr('href') + 'index.php?route=product/search';
		var value = $('#search input[name=\'search\']').val();
		//console.log(value); //value is empty!!
		if (value) {
			url += '&search=' + encodeURIComponent(value);
		}
		location = url;
});
I have no clue what might be going wrong. Why is 'var value' returning empty? Can someone please help me out?

Newbie

Posts

Joined
Sun Aug 13, 2017 5:01 am

Post by cyclops12 » Tue Aug 15, 2017 12:57 am

Have you copied the code for the search from the controller/common/header to your new location ?

Active Member

Posts

Joined
Sun Sep 27, 2015 1:10 am
Who is online

Users browsing this forum: No registered users and 4 guests