jquery-ui - JQuery - resolveWith --- Uncaught TypeError: $(...).draggable is not a function ... at Object.fireWith [as resolveWith] (jquery-1.12.4.js:3362)
问题描述
试图定义一个通用/香草可拖动的功能,。在谷歌搜索之后,我想我已经将问题隔离到了,包括在内的脚本内resolveWith
的冲突,我专注于错误内。
定义用于创建 Draggable -li-list 标记的函数。
<script>
$( function() {
$( "#id_draggable" ).draggable();
} );
</script>
最初错过了包括下面提到的 2 个脚本 ---
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
Chrome 控制台出现错误Uncaught TypeError: $(...).draggable is not a function
Uncaught TypeError: $(...).draggable is not a function jquery-3.3.1.js:3827
at HTMLDocument.<anonymous> ((index):2078)
at mightThrow (jquery-3.3.1.js:3534)
at process (jquery-3.3.1.js:3602)
包含了上面提到的两个脚本——它们位于定义的可拖动函数的正上方——在 Chrome 控制台中再次出现错误
Uncaught TypeError: $(...).draggable is not a function
at HTMLDocument.<anonymous> (localhost/:2080)
at fire (jquery-1.12.4.js:3232)
at Object.fireWith [as resolveWith] (jquery-1.12.4.js:3362)
at Function.ready (jquery-1.12.4.js:3582)
at HTMLDocument.completed (jquery-1.12.4.js:3617)
更改了包含脚本的位置 - 将它们移动到 -head 标记内。Chrome 控制台再次出现错误 -
Uncaught TypeError: $(...).draggable is not a function
at HTMLDocument.<anonymous> ((index):2079)
at fire (jquery-1.12.4.js:3232)
at Object.fireWith [as resolveWith] (jquery-1.12.4.js:3362)
at Function.ready (jquery-1.12.4.js:3582)
at HTMLDocument.completed (jquery-1.12.4.js:3617)
再次更改了包含脚本的位置 - 将它们移动到页面末尾之前,页面正文关闭 TAG。在 Chrome 控制台中再次出现错误 -
Uncaught TypeError: $(...).draggable is not a function
at HTMLDocument.<anonymous> ((index):2078)
at mightThrow (jquery-3.3.1.js:3534)
at process (jquery-3.3.1.js:3602)
编辑 - 1删除,
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
这是包含的脚本之一。让另一个脚本是
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
,留在页面底部的页面主体关闭TAG。错误变为如下所示 -
jQuery.Deferred exception: $(...).draggable is not a function TypeError: $(...).draggable is not a function jquery-3.3.1.js:3818
at HTMLDocument.<anonymous> (http://localhost:8001/dc/eda_action/bhanu1aaccbhanu11aacc25/:2078:56)
at mightThrow (https://code.jquery.com/jquery-3.3.1.js:3534:29)
at process (https://code.jquery.com/jquery-3.3.1.js:3602:12) undefined
jQuery.Deferred.exceptionHook @ jquery-3.3.1.js:3818
process @ jquery-3.3.1.js:3606
Uncaught TypeError: $(...).draggable is not a function jquery-3.3.1.js:3827
at HTMLDocument.<anonymous> ((index):2078)
at mightThrow (jquery-3.3.1.js:3534)
at process (jquery-3.3.1.js:3602)
(anonymous) @ (index):2078
mightThrow @ jquery-3.3.1.js:3534
process @ jquery-3.3.1.js:3602
请注意,较早的错误跟踪没有 -
jQuery.Deferred exception: $(...).draggable is not a function TypeError: $(...).draggable is not a function
EDIT-2似乎我需要按照此处的建议删除所有 JQuery 和 JQuery UI 实例 = https://wordpress.org/support/topic/receiving-javascript-error-stickthis-is-not-a-function/,错误截至目前如下所示...
jQuery.Deferred exception: $(...).draggable is not a function TypeError: $(...).draggable is not a function jquery-3.3.1.js:3818
at HTMLDocument.<anonymous> (http://localhost:8000/dc/eda_action/bhanu1aaccbhanu11aacc25/:2103:42)
at mightThrow (https://code.jquery.com/jquery-3.3.1.js:3534:29)
at process (https://code.jquery.com/jquery-3.3.1.js:3602:12) undefined
jQuery.Deferred.exceptionHook @ jquery-3.3.1.js:3818
process @ jquery-3.3.1.js:3606
解决方案
问题在于可拖动的 LI 列表标签的代码在模态中,因为现在已经移出模态-现在一切都很好。稍后将再次尝试在 Modal 中使用 jQuery Draggable LI 列表标签并在此处报告。
推荐阅读
- android - 我可以先使用 Phonegap,然后再使用 Cordova 吗?
- jenkins - 在 jenkins 的构建步骤中使用构建变量
- sql - 如何在 PostgreSQL 中查找多个子字符串的位置?
- java - 尝试使用原始套接字发送 GET 请求时出现 301
- python - kafka IllegalStateError:生产者被强制关闭
- sql - 如何选择从部分文本开始,以值范围SQL结束
- rust - 如何将大小特征插入到集合中
- excel - 如何使用excel函数用列标签填充单元格?
- javascript - 如何在 HTML5 中使矩形可拖动?
- angular - 读取 zip 文件内容并将其分配给局部变量