Сломал мозг обновление js скрипта под новую версию js плагина
Доброй ночи форумчане столкнулся со стеной в js
Имеем for(i=0;i<$("input.discounted_set_autocomplete").length;i++) { $("input#discounted_set_autocomplete_"+i).autocomplete({ serviceUrl:'ajax/search_products.php', minChars:0, noCache: false, obj: $(this), onSelect: function(value, data, obj){ new_item = obj.parent().find('#new_discounted_set_product').clone().appendTo(obj.parent().find('.discounted_set_products')); new_item.removeAttr('id'); new_item.find('a.discounted_set_product_name').html(data.name); new_item.find('a.discounted_set_product_name').attr('href', 'index.php?module=ProductAdmin&id='+data.id); new_item.find('input.main_hidden').val(data.variant); if(data.image) { new_item.find('img.product_icon').attr("src", data.image); } else { new_item.find('img.product_icon').remove(); var pvid = obj.parent().find('input[name=parent_variant_id]').val(); new_item.find('input.main_hidden').attr('name', 'discounted_set_products[]['+pvid+']'); obj.val(''); new_item.show(); } }, fnFormatResult: function(value, data, currentValue){ var reEscape = new RegExp('(\\' + ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\'].join('|\\') + ')', 'g'); var pattern = '(' + currentValue.replace(reEscape, '\\$1') + ')'; return (data.image?"<img align=absmiddle src='"+data.image+"'> ":'') + value.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); } }); } данный скрипт работает в связке с Ajax Autocomplete for jQuery, version 1.1.3 http://zituo.net/view/14 Решил обновить до Ajax Autocomplete for jQuery, version 1.2.9 https://github.com/devbridge/jQuery-Autocomplete Создатель один и тот же проблема уже 2 день долблюсь и не могу понять как обновить первый js под новую версию Прикладываю файл ajax который обрабатываетя версию для 1.1.3 foreach($products as $product) { if(!empty($product->image)) { $product->image = $simpla->design->resize_modifier($product->image, 35, 35); $products_names[] = $product->name; } else $products_names[] = $product->name; $products_data[] = $product; } $res->query = $keyword; $res->suggestions = $products_names; $res->data = $products_data; header("Content-type: application/json; charset=UTF-8"); header("Cache-Control: must-revalidate"); header("Pragma: no-cache"); header("Expires: -1"); print json_encode($res); 1.2.9 $suggestions = array(); foreach($products as $product) { if(!empty($product->image)) $product->image = $simpla->design->resize_modifier($product->image, 35, 35); $suggestion = new stdClass(); $suggestion->value = $product->name; $suggestion->data = $product; $suggestions[] = $suggestion; } $res = new stdClass; $res->query = $keyword; $res->suggestions = $suggestions; header("Content-type: application/json; charset=UTF-8"); header("Cache-Control: must-revalidate"); header("Pragma: no-cache"); header("Expires: -1"); print json_encode($res); когда чисто логически меняю всё под 1.2.9 Вываливается ошибка obj не указан. Заранее благодарен. Не обязательно писать решение, можно направить в правильное русло |
Часовой пояс GMT +3, время: 05:31. |