jQuery $.widget 不是函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5968803/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 20:07:07  来源:igfitidea点击:

$.widget is not a function

jquery

提问by clarkk

I want to make use of some dragable elements.. but as soon as I load the page I get this

我想使用一些可拖动元素..但是一旦我加载页面我就会得到这个

$.widget is not a function

the code

编码

<script src="js/jquery/jquery-1.6.js" type="text/javascript"></script>

<script src="js/jquery/jquery.ui.core.js" type="text/javascript"></script>
<script src="js/jquery/jquery.ui.draggable.js" type="text/javascript"></script>
<script src="js/jquery/jquery.ui.mouse.js" type="text/javascript"></script>
<script src="js/jquery/jquery.ui.widget.js" type="text/javascript"></script>

采纳答案by Anthony Accioly

Also take a look at this answer about using a Google hosted version. If you can do that, you will get a lot of benefits (see here).

另请查看有关使用Google 托管版本的答案。如果您能做到这一点,您将获得很多好处(请参阅此处)。

回答by Greg

Place your widget.js after core.js, but before any other jquery that calls the widget.js file. (Example: draggable.js) Precedence (order) matters in what javascript/jquery can 'see'. Always position helper code before the code that uses the helper code.

将widget.js 放在core.js 之后,但在调用widget.js 文件的任何其他jquery 之前。(例如:draggable.js)优先级(顺序)在 javascript/jquery 可以“看到”的内容中很重要。始终将帮助代码放在使用帮助代码的代码之前。

回答by jerone

Maybe placing the jquery.ui.widget.jsas second after jquery.ui.core.js.

也许将jquery.ui.widget.jsas放在jquery.ui.core.js.

回答by Gogol

May be include Jquery Widget first, then Draggable? I guess that will solve the problem.....

可能是先包含 Jquery Widget,然后是 Draggable?我想这将解决问题......

回答by Gerard ONeill

I got this error recently by introducing an old plugin to wordpress. It loaded an older version of jquery, which happened to be placed before the jquery mouse file. There was no jquery widget file loaded with the second version, which caused the error.

我最近通过向 wordpress 引入一个旧插件而得到这个错误。它加载了旧版本的jquery,恰好放在jquery鼠标文件之前。没有加载第二个版本的jquery小部件文件,导致错误。

No error for using the extra jquery library -- that's a problem especially if a silent fail might have happened, causing a not so silent fail later on.

使用额外的 jquery 库没有错误——这是一个问题,特别是如果可能发生了静默失败,稍后会导致不那么静默的失败。

A potential way around it for wordpress might be to be explicit about the dependencies that way the jquery mouse would follow the widget which would follow the correct core leaving the other jquery to be loaded afterwards. Still might cause a production error later if you don't catch that and change the default function for jquery for the second version in all the files associated with it.

wordpress 的一个潜在解决方法可能是明确依赖关系,这样 jquery 鼠标将跟随小部件,该小部件将跟随正确的核心,而其他 jquery 将在之后加载。如果您没有发现它并在与它相关的所有文件中更改第二个版本的 jquery 的默认函数,那么稍后仍然可能会导致生产错误。