从 mootools 可排序中删除元素
我正在尝试从 mootools 可排序列表中删除一个项目,然后序列化并保存新列表。
我想在元素上使用一些养眼的东西,而不是直接使用 destroy()
。我在这里构建了一个小提琴: http://jsfiddle.net/kBAqJ/4/
请注意order1
和 order2
变量。它保存删除项目之前和之后的序列化元素。如果您在从可排序对象中删除元素后使用 destroy
方法删除该元素,则您将获得 order2
的正确值,例如: 4.
如果您使用 nix(true)
而不是 destroy
,您将得到 5 作为 order1
和 order2
的值>,尽管文档说 nix(true)
在 dissolve
之后调用 destroy
。
这是 Mootools 中的错误,还是我遗漏了什么?是否有不同的方法来添加 dissolve
效果,同时仍然使用 destroy
来获得正确的结果?
window.addEvent('domready', function(){
var mySort = new Sortables('#example2 UL', {
clone: true,
revert: true,
opacity: 0.7
});
console.log (mySort.elements.length);
var order1 = mySort.serialize(0);
console.dir(order1);
mySort.removeItems($('item1')).destroy(); // this results in the correct value in the order2 var below
//mySort.removeItems($('item1')).nix({duration: 1000}, true); // this results in the wrong value for order2
console.log (mySort.elements.length);
var order2 = mySort.serialize(0);
console.dir(order2);
});
I'm trying to remove an item from a mootools sortable list, then serialize and save the new list.
I'd like to use a little bit of eye-candy rather than a straight destroy()
on the element. I've built a fiddle here: http://jsfiddle.net/kBAqJ/4/
Note the order1
and order2
vars. This holds the serialized element before and after removing the item. If you use the destroy
method to get rid of the element after removing it from the sortable, you get the right value for order2
, eg. 4.
If you use nix(true)
instead of destroy
, you get 5 as the value of order1
and order2
, even though the docs say that nix(true)
calls destroy
after dissolve
.
Is this a bug in Mootools, or am I missing something? Is there a different way to add a dissolve
effect while still using destroy
that will get the right result?
window.addEvent('domready', function(){
var mySort = new Sortables('#example2 UL', {
clone: true,
revert: true,
opacity: 0.7
});
console.log (mySort.elements.length);
var order1 = mySort.serialize(0);
console.dir(order1);
mySort.removeItems($('item1')).destroy(); // this results in the correct value in the order2 var below
//mySort.removeItems($('item1')).nix({duration: 1000}, true); // this results in the wrong value for order2
console.log (mySort.elements.length);
var order2 = mySort.serialize(0);
console.dir(order2);
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您不会找到任何会破坏元素并仍然在页面上显示它的效果或方式;)所以这不是 moo 工具错误
序列化函数正在使用列表的子项(即 < code>
我想说最简单的方法是在序列化数组中删除它们的引用:
干杯
i don't think you'll find any effect or way which will destroy the element and still show it on the page ;) So it is not a moo tools bug
The serialize function is using the children of the list (ie. the
<li>
blocks) to make the array.I would say the easiest way would be to get rid of their reference in the serialized array:
Cheers