繁体   English   中英

如何在文本输入中添加放置区域?

[英]How to add a drop area to the text input?

我正在尝试从数据表到Webix文本输入实现DnD。 实际上,我为html输入找到了一个示例

    webix.DragControl.addDrop("mytext", {       // "mytext" is a DIV id
        $drop:function(source, target, event){
            var dnd = webix.DragControl.getContext();
            target.value = dnd.from.getItem(dnd.source[0]).title;
        }
    })

但是我该如何将DropDrop添加到Webix ui.text中呢? 是否可以将DIV ID替换为某些内容? 关键是内部输入的ID是动态的(存储到您重新加载页面之前才存储),因此我看不到任何易于理解的方法来向其中添加放置区域。 任何想法表示赞赏。

这是基于先前示例的演示: http : //webix.com/snippet/14cbbeec

肮脏的解决方案是将addDrop添加到webix小部件的$ view属性(= DOM元素):

webix.DragControl.addDrop($$('webixText').$view, {
  $drop:function(source, target, event){
    var dnd = webix.DragControl.getContext();
    // target is the DOM element, so have to access webix widget with id
    $$('webixText').setValue(dnd.from.getItem(dnd.source[0]).title);
  }
});

更新的代码段: http : //webix.com/snippet/77363e5a

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM