我使用的是opencart框架,并且我在首页进行了自动完成搜索,效果很好,但是它无法重定向到我搜索过的产品的搜索页面,任何人都可以帮忙,请 这段代码是search.twig,这是输入搜索的代码,下面是自动完成搜索
<div class="panel-body">
<div class="form-group">
<label class="control-label" for="input-name">{{ entry_name }}
</label>
<input type="text" name="filter_name"
value="{{ filter_name }}" placeholder="{{ entry_name }}"
class="search_input id="input-name" class="form- control" />
</div>
<div class="form-group text-right">
<button type="button" id="button-filter" class="search_bttn" > Search</button>
</div>
<script type="text/javascript">
$('#button-filter').on('click', function() {
var url = '';
var filter_name = $('input[name=\'filter_name\']').prop('value');
if (filter_name) {
url += '&filter_name=' + encodeURIComponent(filter_name);
}
location = 'index.php?route=product/search' + url;
});
</script>
<script type="text/javascript"><!--
// IE and Edge fix!
$('button[form=\'form-product\']').on('click', function(e) {
$('#form-product').attr('action', $(this).attr('formaction'));
});
$('input[name=\'filter_name\']').autocomplete({
'source': function(request, response) {
$.ajax({
url: 'index.php?route=product/product/autocomplete&filter_name=' +
encodeURIComponent(request),
dataType: 'json',
success: function(json) {
response($.map(json, function(item) {
return {
label: item['name'],
value: item['product_id']
}
}));
}
});
},
'select': function(item) {
$('input[name=\'filter_name\']').val(item['label']);
}
});
</script>