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')
|
@push('js')
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
|
const articleShowUrlTemplate = "{{ route('Shop.Articles.show', ['id' => '__ARTICLE_ID__']) }}";
|
||||||
|
|
||||||
$('#search-general .fa-search').click(function() {
|
$('#search-general .fa-search').click(function() {
|
||||||
$('#search-general').submit();
|
$('#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>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|||||||
@@ -13,9 +13,10 @@
|
|||||||
var id = item.value;
|
var id = item.value;
|
||||||
$('#' + field).val(id);
|
$('#' + field).val(id);
|
||||||
|
|
||||||
if (typeof(callback) != 'undefined') {
|
if (typeof callback === 'function') {
|
||||||
var c = callback + '(' + id + ')';
|
callback.call(this, item, evt);
|
||||||
eval(c);
|
} else if (typeof callback === 'string' && callback.length && typeof window[callback] === 'function') {
|
||||||
|
window[callback].call(this, item, evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user