Im trying to add very simple autocomplete function to my prestashop addon input. What I want to achieve is something like this:
city.php
city.php
<label for="city">City: </label>
And auto.js$(function() {
var availableTags = [
"London",
"Manchester",
"Liverpool",
];
$( "#city" ).autocomplete({
source: availableTags
});
The problem is that I dont know how to call jquery library in
prestashop. I was trying to add something like this in my addon class:$this->context->controller->addJqueryPlugin('autocomplete');
With no luck...
Answer:
1:In controllers you can add any JS files with
$this->addJS(_THEME_JS_DIR_.'index.js');
So, you can put this plugin to theme_folder/js/plugins/autocomplite.js and add it with $this->addJS(_THEME_JS_DIR_.'plugins/autocomplite.js');2: |
In Prestashop 1.6, using hook function, you can do something like this (actualy i'm using it inside a custom module) :
As you can see, i'm adding Fancybox, Bootstrap and DateTimePicker. You should add your own plugins inside js directory, inside your theme or module. Calling a plugin in theme is easy using smarty ($js_dir i guess, or $tpl_dir) EDIT : Here's a sample of autocomplete in Prestashop : TPL :
And here's autocomplete using Jquery :
Assuming your php file is returning correct values. Prefere use your own HTML, overriding tpl in your theme. |
No comments:
Post a Comment