I added a custom field named product_type in Product admin. It works well, but now, I'm trying to add an autocomplete to this field.
Here is my code (in \mysite\admin\themes\default\template\controllers\products\informations.tpl
)
<td style="padding-bottom:5px;">
<input size="55" type="text" id="product_type" name="product_type" value="{$product->product_type|escape:html:'UTF-8'}" style="width: 130px; margin-right: 5px;" />
<script type="text/javascript">
$(document).ready(function() {
$('#product_type').autocomplete({
source: function(request, response) {
$.ajax({
url: "ajax.php",
dataType: "json",
data: { term: request.term, ajaxProductType: 1 },
success: function(data) { response(data); }
});
},
minLength: 3,
select: function( event, ui ) {
$(this).val(ui.item.value);
}
});
});
</script>
</td>
When I write in the field, nothing happen. The autocomplete is not called. No error in console. However, when I put an alert()
in the document.ready
function, it shows. So, why my autocomplete doesn't work?
Version : Prestashop 1.5.6
Thanks in advance for your help