Friday, 23 August 2013

How to add JS for modules in prestashop 1.5?

How to add JS for modules in prestashop 1.5?

Am developing a module in prestashop 1.5. Am using
displayAdminProductsExtra hook to display tpl file in admin tab. when i
include my jquery code in tpl, it works fine. but when i try to make it as
new file and include its not working. so far I tried the below methods..
using displayBackOfficeHeader to register a hook and called like this..
public function hookdisplayBackOfficeHeader($params)
{
$this->context->controller->addJS(($this->_path).'abc.js');
}
and I tried to add it in displayAdminProductsExtra also like this..
$this->context->controller->addJS(_MODULE_DIR_.$this->module->name.'/views/js/abc.js');
//first tried..
$this->context->controller->addJS(($this->_path).'abc.js','all'); //second
tried this..
And I tried with getcontent like this..
public function getContent()
{
$this->_html= '<script
src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js">
<script src="../modules/abc/abc.js" type="text/javascript"
></script>';
return $this->_html;
}
but these methods didn't add my js file. Dont know where am making
mistake.any help would be appreciated.

No comments:

Post a Comment