douji6940
2017-07-27 21:44
浏览 34
已采纳

在prestashop 1.7的管理模块中启用jquery2

I'm using prestashop 1.7.2.0 to write an admin module that adds nested categories and products from a csv file. I understood that addJQuery() is deprecated and I'm trying to get jquery code to work. I get Uncaught ReferenceError: $ is not defined.

I have created a displayBackOfficeHeader hook with the following:

public function hookDisplayBackOfficeHeader(){
    $this->context->controller->addJS($this->_path.'/js/jqShim.min.js');
    $this->context->controller->addCSS($this->_path.'/css/getcontent.css');
    $this->context->controller->addJS($this->_path.'/js/getcontent.js');
}

as you can see I have tried including jqShim.min.js and I still got the same error. what am I missing?

Thanks

图片转代码服务由CSDN问答提供 功能建议

我正在使用prestashop 1.7.2.0编写一个管理模块,用于添加csv文件中的嵌套类别和产品。 我知道 addJQuery()已被弃用,我正试图让jquery代码工作。 我得到Uncaught ReferenceError:$未定义

我创建了一个 displayBackOfficeHeader 钩子,其中包含以下内容: \ n

  public function hookDisplayBackOfficeHeader(){
 $ this-> context-> controller-> addJS($ this-> _path。'/ js / jqShim.min.js')  ; 
 $ this-> context-> controller-> addCSS($ this-> _path。'/ css / getcontent.css'); 
 $ this-> context-> controller->  addJS($ this-> _path。'/ js / getcontent.js'); 
} 
   
 
 

你可以看到我试过包含 jqShim.min.js 我仍然遇到同样的错误。 我错过了什么?

谢谢

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • drvxnivoqf17568697 2017-07-28 05:58
    已采纳

    You can include $this->context->controller->addJquery(); in first line of your hookDisplayBackOfficeHeader() function.

    打赏 评论

相关推荐 更多相似问题