new: make click in choices of search box load the page of the product
This commit is contained in:
@@ -16,11 +16,27 @@
|
||||
@push('js')
|
||||
<script>
|
||||
$(function() {
|
||||
const articleShowUrlTemplate = "{{ route('Shop.Articles.show', ['id' => '__ARTICLE_ID__']) }}";
|
||||
|
||||
$('#search-general .fa-search').click(function() {
|
||||
$('#search-general').submit();
|
||||
});
|
||||
|
||||
initAutocomplete('#search_name');
|
||||
function redirectToArticle(item, evt) {
|
||||
if (!item || typeof item.value === 'undefined' || item.value === null || item.value === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (evt) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
}
|
||||
|
||||
const targetUrl = articleShowUrlTemplate.replace('__ARTICLE_ID__', item.value);
|
||||
window.location.href = targetUrl;
|
||||
}
|
||||
|
||||
initAutocomplete('#search_name', redirectToArticle);
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
var id = item.value;
|
||||
$('#' + field).val(id);
|
||||
|
||||
if (typeof(callback) != 'undefined') {
|
||||
var c = callback + '(' + id + ')';
|
||||
eval(c);
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(this, item, evt);
|
||||
} else if (typeof callback === 'string' && callback.length && typeof window[callback] === 'function') {
|
||||
window[callback].call(this, item, evt);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user