【问题标题】:Prestashop change references order to the scripts in head tagPrestashop 更改对 head 标签中脚本的引用顺序
【发布时间】:2018-08-10 06:00:02
【问题描述】:

我使用的是 Prestashop 版本 1.6.1.17。我安装了一个名为 Super Abandoned Cart 的模块,在 Prestashop 后台出现以下错误:

未捕获的引用错误:$ 未定义

我发现我应该把对 jquery 脚本的引用放在第一位。

我不知道如何在 Prestashop 中做到这一点。

这些是安装某些模块(PrestaQnA 和 Super Abandoned Cart)后自动生成的参考:

<script type="text/javascript" src="/modules/prestaqna/js/dh42.js"></script>
<script type="text/javascript" src="/modules/superabandonedcart/views/js/js.js"></script>
<script type="text/javascript" src="/js/jquery/jquery-1.11.0.min.js"></script>

【问题讨论】:

  • 您是否尝试过更改后台中的模块位置 -> 模块 -> 位置?
  • @sadlyblue 问题是我在后台有这个错误

标签: jquery prestashop-1.6 head


【解决方案1】:

我找到了解决办法:

在 prestashop 中,加载 jQuery 文件,我们使用 addJquery() 函数。

为了在任何其他文件之前加载 jQuery 文件,您可能需要在加载任何其他 js 文件之前调用此函数。

例如

public function hookBackOfficeHeader()
{
    if (Tools::getValue('module_name') == $this->name) {
        $this->context->controller->addJquery();
        $this->context->controller->addJS($this->_path . 'views/js/back.js');
    }
}

参考: https://www.prestashop.com/forums/topic/310898-force-jquery-to-load-as-the-first-js-file-before-any-other-js-files/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-03
    • 1970-01-01
    • 2019-03-20
    • 1970-01-01
    • 2013-09-05
    相关资源
    最近更新 更多