jQueryUI无法正常运行(在Prestashop中)如何进行故障排除? [英] jQueryUI not working (in Prestashop) how to troubleshoot?

查看:102
本文介绍了jQueryUI无法正常运行(在Prestashop中)如何进行故障排除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Prestashop构建一个具有Front Office Controller的模块. 我想使用jQueryUI.

I am building a Module for Prestashop that has a Front Office Controller. I'm wanting to use jQueryUI.

在我包含在JQueryUI中的模块的主要php文件中(扩展Module类),如下所示:

In my main php file for the module (extending the Module class) in included JQueryUI like this:

    public function hookHeader()
{
    $this->context->controller->addJqueryUI('ui.core');
    $this->context->controller->addJqueryUI('ui.widget');
    $this->context->controller->addJqueryUI('ui.mouse');
    $this->context->controller->addJqueryUI('ui.slider');
}

我正在检查标题,并且看到所有脚本都以正确的顺序包含在内. (参见图片)jQuery本身就可以正常工作.但是,当我调用jQueryUI方法时,它说该方法未定义.

I am checking my header, and I see all the scripts are being included in the correct order. (See image) jQuery all by itself works fine. But as soon as I'm calling a jQueryUI method, it says the method is not defined.

我只是想让基本示例开始工作,两种不同的方法都无效.

I'm just trying to get the basic example to work, two different ways, both don't work.

$(document).ready(function(){
    $( "#date" ).datepicker();
});

这也不起作用:

$( function() {
    $( "#date" ).datepicker();
} );

它总是说$(...).datepicker is not a function.

看起来jQuery 包含两次,因为它在我不调用任何UI方法时都可以正常工作.只是这种迁移"的事情,但是,如果我重命名该文件,使其无法被包含,它将引发很多不同的错误(其他功能突然发现未定义).

It doesn't look like jQuery is included twice, since it works fine when I don't call any of the UI methods. There's just this "migration" thing, but if I rename the file so it can't be included it throws a whole host of different errors (other functions it suddenly finds undefined).

我已经禁用了除我之外的所有模块.同样的问题.

Also I've already disabled all modules but mine. Same problem.

足够有趣

window.onload = function() {
   if (typeof jQuery.ui !== 'undefined') {  
        alert("jquery ui is loaded!");
    } else {
        alert("not working");
    }
}

这说它已经装好了!

可能是什么问题?

如何解决这个问题?

推荐答案

您需要指定加载日期选择器.

What you need to do is specify to load datepicker.

$this->context->controller->addJqueryUI('ui.datepicker');

Prestashop中的jQuery UI带有每个UI组件的单独文件.因此,您需要指定要加载的组件.

jQuery UI in Prestashop comes with separate files for each UI component. So you need to specify which component to load.

在文件夹/js/jquery中查看/ui ,您将看到可用的组件.

Have a look in folder /js/jquery/ui and you will see which components are available.

不需要指定ui.core, ui.mouse等(除非您仅特别需要它们),因为它们是组件的依赖项,因此除非您在addJqueryUI方法中向false添加第三个参数,否则它们会自动加载.

There is no need to specify ui.core, ui.mouse etc. (unless you specifically need them only) because they are dependencies of components so they get auto loaded unless you add third parameter in addJqueryUI method to false.

每个组件的依赖性在中定义媒体类.

Dependencies for each component are defined in Media class.

对话框的示例自动加载的组件的依赖项:

Example of dialog component's dependencies that are automatically loaded:

'ui.dialog' => array('fileName' => 'jquery.ui.dialog.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position','ui.button'), 'theme' => true),

这篇关于jQueryUI无法正常运行(在Prestashop中)如何进行故障排除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆