JQuery 手风琴在拖放后不会自行打开
我有以下 HTML 逻辑块:
- 第一个是可排序的 手风琴列表
- 第二个是列表 可拖动的手风琴。这些元素可以添加到可排序的手风琴中。
此处演示: http://jsfiddle.net/t3tVA/
所以我想按顺序移动我的可拖动元素使用可排序的手风琴添加它们。 它工作得很好,除了当我的元素被放在可排序的手风琴中时,它无法打开。
这是我的 JavaScript 代码:
$(function() {
$( "> div", "#questionsDispos" ).draggable({
helper: "clone",
revert: "invalid",
cursor: "move",
handle: "h3",
connectToSortable: ".questions"
});
$( ".questions" ).accordion({
header: "> div > h3",
collapsible: true,
active: false,
autoHeight: false
}).sortable({
handle: "h3",
receive: function(event, ui) {
$(ui.item).removeClass();
$(ui.item).removeAttr("style");
}
});
$( "#questionsDispos" ).accordion({
header: "> div > h3",
collapsible: true,
active: false,
autoHeight: false
});
});
这是我的 HTML:
<div class="questions">
<div>
<h3><a href="#">Question 1. My First Question ?</a></h3>
<div>
First content<br />
</div>
</div>
<div>
<h3><a href="#">Question 2. My Second Question ?</a></h3>
<div>
Second content<br />
</div>
</div>
<div>
<h3><a href="#">Question 3. My Third Question ?</a></h3>
<div>
Third content<br />
</div>
</div>
</div>
Questions disponibles :<br />
<div id="questionsDispos">
<div>
<h3><a href="#">Something</a></h3>
<div>
My Content Here<br />
</div>
</div>
</div>
请注意,我使用 jquery-ui-1.8.11.custom.min.patch.js 的修补版本,以便在可排序的接收事件中使用 ui.item。 (我用它来删除一些类,以使移动的元素看起来像其他元素)。 您可以在这里下载:http://www.toofiles .com/fr/oip/documents/js/jquery-ui-1811customminpatch.html
编辑:我在这里发布了一个演示,以便您可以测试它:http://jsfiddle.net/t3tVA/ 正如您所看到的,当您将“某物”放在顶部的手风琴中时,它就无法再打开
有人有解决方案吗? 谢谢
I have the following HTML logical blocks :
- The first one is a sortable
accordions list - The second is a list
of draggable accordions. Those elements can be added to the sortable accordions.
Demo here : http://jsfiddle.net/t3tVA/
So I would like to move my draggable elements in order to add them with the sortable accordions.
It works fine, excepts that when my element is dropped among the sortable accordions, it cannot be opened.
Here is my JavaScript code :
$(function() {
$( "> div", "#questionsDispos" ).draggable({
helper: "clone",
revert: "invalid",
cursor: "move",
handle: "h3",
connectToSortable: ".questions"
});
$( ".questions" ).accordion({
header: "> div > h3",
collapsible: true,
active: false,
autoHeight: false
}).sortable({
handle: "h3",
receive: function(event, ui) {
$(ui.item).removeClass();
$(ui.item).removeAttr("style");
}
});
$( "#questionsDispos" ).accordion({
header: "> div > h3",
collapsible: true,
active: false,
autoHeight: false
});
});
And here is my HTML :
<div class="questions">
<div>
<h3><a href="#">Question 1. My First Question ?</a></h3>
<div>
First content<br />
</div>
</div>
<div>
<h3><a href="#">Question 2. My Second Question ?</a></h3>
<div>
Second content<br />
</div>
</div>
<div>
<h3><a href="#">Question 3. My Third Question ?</a></h3>
<div>
Third content<br />
</div>
</div>
</div>
Questions disponibles :<br />
<div id="questionsDispos">
<div>
<h3><a href="#">Something</a></h3>
<div>
My Content Here<br />
</div>
</div>
</div>
Please note that I use a patched version of jquery-ui-1.8.11.custom.min.patch.js in order to use ui.item in the receive event of sortable. (I use it to remove some classes in order to make the moved element look like the other ones).
You can download it here : http://www.toofiles.com/fr/oip/documents/js/jquery-ui-1811customminpatch.html
EDIT : I posted a demo here so you can test it : http://jsfiddle.net/t3tVA/
As you can see, when you drop "Something" among the accordions on the top, it can not be opened anymore
Does anyone has a solution ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据此错误,这不是您现在可以开箱即用的操作。但是,如果您查看错误报告,有人通过向代码库添加额外的 autoActive 选项提供了解决方案。
另一种方法是销毁手风琴并在手风琴中掉落一个元素后重建。工作示例:
http://jsfiddle.net/t3tVA/1/
According to this bug, this isn't something you can do now out of the box. However, if you look at the bug report someone has provided a solution by adding an extra autoActive option to the codebase.
An alternative is to destroy the accordion and rebuild after a element has been dropped in your accordion. Working sample:
http://jsfiddle.net/t3tVA/1/