【发布时间】:2015-09-02 16:05:21
【问题描述】:
我有一个列表和一些输入字段。我想将列表项拖到输入字段中,并在更新回调中,获取目标输入字段 - 因为我想将列表项的文本复制到输入字段的 value 属性中。我也不希望列表项从其原始位置消失。这就是我所做的:
<ul id="field_source">
<li>some text</li>
<li>some other text</li>
</ul>
<ul class="designer_row connectRow">
<li>
<input type="text" class="connectColumn" /><input type="text" class="connectColumn" />
</li>
</ul>
$( "#field_source, input" ).sortable({
connectWith: ".connectColumn",
forcePlaceholderSize: false,
helper: function(e,li) {
copyHelper= li.clone().insertAfter(li);
return li.clone();
},
stop: function(event, ui) {
copyHelper && copyHelper.remove();
},
update: function(event, ui){
// both ui.item and this are giving me the item dragged, not the element dropped on (the input field)
}
})
如何确定目标输入字段?
【问题讨论】:
-
event.target应该是目标 -
event.target 给了我#field_source ul 元素,而不是输入字段。