jQueryUI操作可拖动克隆 [英] jQueryUI manipulate draggable clone

查看:132
本文介绍了jQueryUI操作可拖动克隆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将这个问题修剪了下来,并放在

I Trimmed this question down, and put it on

查看更改后的原始项目而不是新项目 http://jsfiddle.net/mikkelbreum/DBG5q

See how it's the original and not the new item that gets altered http://jsfiddle.net/mikkelbreum/DBG5q

查看被拖动的辅助对象如何更改,但是元素在放下后会恢复原状. http://jsfiddle.net/mikkelbreum/dpTC8

See how the dragged helper gets altered, but the element reverts back once it's dropped. http://jsfiddle.net/mikkelbreum/dpTC8

我有一个可拖动列表,链接到可排序列表

I've got a draggable list linked to a sortable list

当我从可拖动对象拖动到可排序对象时,我使用了克隆的帮助器,因此原始对象仍留在可拖动对象集合中.

When I drag from draggable to sortable I use a cloned helper, so the original is still left in draggable collection.

每次将克隆从可拖动列表拖动到可排序列表时,我都想给新副本一个唯一的标题(操纵它的h2元素).

each time I drag a clone from the draggable list to the sortable list, I want to give the new copy a unique headline (manipulate it's h2 element).

我找不到解决新创建元素的方法.

I can't find a way to address the newly created element.

我尝试了两种方法:

一种方法是在可拖动对象中的开始事件处定位辅助克隆. 这里的问题是,尽管辅助克隆确实发生了更改,但是在可排序列表中创建该更改时,该更改不会复制到最终元素上.在此处创建的新元素将其作为克隆的可拖动列表中的原始值作为其值.

One is to target the helper clone at the start event in the draggable. The problem here is, that although the helper clone does get changed, that change it is not copied over to the final element when it is created in the sortable list. The new element created there takes the value of the original in the draggable list of which it is a clone.

start: function(event, ui) {

ui.helper.find('h2').text('altered');

}

当我开始拖动时,我可以看到克隆上已更改的更改,但是当将其放到可排序对象上时,h2将重置为原始标题.

I can se the changes to altered on the clone when I start dragging, but when it is dropped on the sortable, the h2 is reset to the original heading.

因此,现在我尝试了一种辅助方法,而是尝试在sortable的receive事件中更改新的原件:

So now I've tried a secondary approach where I instead try to alter the new original in the receive event of the sortable:

receive: function(event, ui) {

ui.item.find('h2').text('altered');

}

这会更改我从中拖动元素的列表中原始元素的h2,但是在sortable内部创建的新元素仍然是旧的原始元素.

This alters the h2 of the original element over in the list I dragged the element from, but the new element that is created inside sortable is still as the old original..

如何定位/更改?

推荐答案

问题似乎是由于 jQueryUI错误

另请参阅: jQuery UI Draggable/Sortable-获取对新项目的引用

这篇关于jQueryUI操作可拖动克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆