leth11 Posted April 30, 2012 Share Posted April 30, 2012 Hi all, how do you add your won javascript file in a prestashop module, in 1.5? I tried all methods i could find on google but it's just not working. if i use addJS it says is deprecated and more than that it just doesn't work. Please Help! Link to comment Share on other sites More sharing options...
Dev On Web Posted May 2, 2012 Share Posted May 2, 2012 Hi, now uses : $this->context->controller->addCSS(); $this->context->controller->addJS(); 1 Link to comment Share on other sites More sharing options...
leth11 Posted May 2, 2012 Author Share Posted May 2, 2012 Hi, now uses : $this->context->controller->addCSS(); $this->context->controller->addJS(); Ok, but i can't make it work. I have my js in the same page with my tpl file i want the js to append. I tried : $this->context->controller->addJS('jsName.js'); (not working) I think i am doing it wrong, can you give me an example with directory paths and such? I would appreciate it greatly. Thanks. Link to comment Share on other sites More sharing options...
Dev On Web Posted May 2, 2012 Share Posted May 2, 2012 Ha ok! So, if your JS is in your theme directory, try: $this->context->controller->addJS(_THEME_JS_DIR_.'[color=#343943][font=Arial,Helvetica,sans-serif][size=3]jsName.js[/size][/font][/color]'); Uses the PS defines vars 1 Link to comment Share on other sites More sharing options...
haunter Posted February 4, 2014 Share Posted February 4, 2014 (edited) Tried: Controller::addJS();not working, $this->context->controller->addJS worked. Edited February 4, 2014 by haunter (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted February 4, 2014 Share Posted February 4, 2014 in prestashop 1.5 proper way is $this->context->controller->addJS(library); 1 Link to comment Share on other sites More sharing options...
Recommended Posts