【发布时间】:2012-11-16 15:14:38
【问题描述】:
正如标题所说,我的 Javascript 在发布时停止工作(这是在服务器上)。 (这是关于 Draggable/Droppable 的,一个 Droppable 应该只包含一个 Draggable)。
这是我的 Javascript 代码:
function pageLoad() {
$('.droppable').droppable({
hoverClass: "ui-state-active",
drop: function (event, ui) {
$(this).droppable('option', 'accept', ui.draggable);
},
out: function (event, ui) {
$(this).droppable('option', 'accept', '.draggable');
},
create: function (event, ui) {
if ($(this).find('.draggable').length == 1) {
$(this).droppable('option', 'accept', $(this).find('.draggable'));
}
},
});
$('.draggable').draggable({
revert: 'invalid',
cursor: 'move',
zIndex: 10000
});
}
好的,所以我使用了这篇文章中的一些解决方案:jQuery UI - Droppable only accept one draggable 有人说:“快速说明:这仅适用于自 jQuery 1.6 以来” – Narretz Jun 4 at 17:21。当我在我发布的版本上运行它时,JQuery 根本不起作用,没有一个对象是可拖动的。
我做过的一个测试 - 从脚本中取出这段代码:
drop: function (event, ui) {
$(this).droppable('option', 'accept', ui.draggable);
},
out: function (event, ui) {
$(this).droppable('option', 'accept', '.draggable');
},
create: function (event, ui) {
if ($(this).find('.draggable').length == 1) {
$(this).droppable('option', 'accept', $(this).find('.draggable'));
}
},
所以至少现在发布版本中的拖放工作,但我仍然想要最大的一个功能。
我的 Javascript 文件是这样引用的:
<script src="jquery.min.js" type="text/javascript"></script>
<script src="jquery-ui.min.js" type="text/javascript"></script>
我的脚本文件在该文件夹中,本地和服务器上。
所以我怀疑“jQuery 1.6”。有人知道吗?
对不起,我的文字墙。提前谢谢
/里卡德
【问题讨论】:
-
您当然也包含了 jQuery UI,并通过在控制台的网络选项卡中检查 404 来验证位置是否正确。
-
控制台有错误吗?
-
@adeno:你是说我的 jquery-ui.min.js 文件?
-
@gpojd:运行调试器时没有错误。
标签: jquery publish jquery-droppable jquery-draggable