Порядок выполнения скрипта Jquery
есть ajax запрос live search и отдельная функция для подсветки вводимых слов у выпадающем меню autocomlete. Вводимый текст в поиске подсвечивает набранный текст на секунду и пропадает.
Как настроить приоритет выполнения скрипта, что бы подсветка вводимых слов не пропадала?
<script type="text/javascript"><!--
//функция подсветки вводимых слов
function light() {
///////// код скрипта подсветки
}
var live_search = {
selector: '#search input[name=\'search\']',
text_no_matches: '<?php echo $text_empty; ?>',
height: '50px'
}
$(document).ready(function() {
var html = '';
html += '<div class="live-search">';
html += ' <ul>';
html += ' </ul>';
html += '<div class="result-text"></div>';
html += '</div>';
//$(live_search.selector).parent().closest('div').after(html);
$(live_search.selector).after(html);
$(live_search.selector).autocomplete({
'source': function(request, response) {
var filter_name = $(live_search.selector).val();
var live_search_min_length = '<?php echo (int)$live_search_min_length; ?>';
if (filter_name.length < live_search_min_length) {
$('.live-search').css('display','none');
}
else{
var html = '';
html += '<li style="text-align: center;height:10px;">';
html += '<img class="loading" src="catalog/view/theme/default/image/loading.gif" />';
html += '</li>';
$('.live-search ul').html(html);
$('.live-search').css('display','block');
$.ajax({
url: 'index.php?route=product/live_search&filter_name=' + encodeURIComponent(filter_name),
dataType: 'json',
success: function(result) {
var products = result.products;
$('.live-search ul li').remove();
$('.result-text').html('');
if (!$.isEmptyObject(products)) {
var show_image = <?php echo $live_search_show_image;?>;
var show_price = <?php echo $live_search_show_price;?>;
var show_description = <?php echo $live_search_show_description;?>;
$('.result-text').html('<a href="<?php echo $live_search_href;?>'+filter_name+'" class="view-all-results"><?php echo $text_view_all_results;?> ('+result.total+')</a>');
$.each(products, function(index,product) {
var html = '';
html += '<li>';
html += '<a href="' + product.url + '" title="' + product.name + '">';
html += ' <p> Артикул ' + product.sku +'</p>';
if(product.image && show_image){
html += ' <div class="product-image"><img alt="' + product.name + '" src="' + product.image + '"></div>';
}
html += ' <div class="product-name">' + product.name;
if(show_description){
html += '<p>' + product.extra_info + '</p>';
}
html += '</div>';
if(show_price && product.price){
if (product.special) {
html += ' <div class="product-price"><span class="special">' + product.price + '</span><span class="price">' + product.special + '</span></div>';
} else {
html += ' <div class="product-price"><span class="price">' + product.price + '</span></div>';
}
}
html += '<span style="clear:both"></span>';
html += '</a>';
html += '</li>';
$('.live-search ul').append(html);
});
//////////////////////////////////
light(); // Вызов скрипта подсветки
/////////////////////////////////////////////
}
});
}
},
//////// далее другие скрипты
//--></script>