2
正在prestashop 1.5中開發一個模塊。我正在使用displayAdminProductsExtra掛鉤在admin選項卡中顯示tpl文件。當我在tpl中包含我的jquery代碼時,它工作正常。但是當我嘗試將其作爲新文件幷包含其不工作時。到目前爲止,我嘗試下面的方法..如何在prestashop 1.5中添加JS模塊?
使用displayBackOfficeHeader註冊一個鉤子,並呼籲這樣的..
public function hookdisplayBackOfficeHeader($params)
{
$this->context->controller->addJS(($this->_path).'abc.js');
}
,我試着將它添加在displayAdminProductsExtra也是這樣..
$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..
我試圖用這樣的getContent ..
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;
}
但這些方法沒有添加我的js文件。不知道我在哪裏犯錯。任何幫助將不勝感激。
[看看本作詳細的解答](http://www.vipulhadiya.com/prestashop-module-development-tutorial-creating-front-and-admin-view-in-prestashop-module /) –
下次再說。 –