简体   繁体   English

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

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

I'm trying to implement DnD from the datatable to the Webix text input. 我正在尝试从数据表到Webix文本输入实现DnD。 Actually, I found a sample for an html input: 实际上,我为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;
        }
    })

But how can I addDrop to a Webix ui.text instead? 但是我该如何将DropDrop添加到Webix ui.text中呢? is it possible to replace the DIV id with something? 是否可以将DIV ID替换为某些内容? The point is that the ID of the inner input is dynamic (stored until you reload the page), so I don't see any easy to understand method to add drop area to it. 关键是内部输入的ID是动态的(存储到您重新加载页面之前才存储),因此我看不到任何易于理解的方法来向其中添加放置区域。 Any ideas are appreciated. 任何想法表示赞赏。

Here's a demo based on the previous sample: http://webix.com/snippet/14cbbeec 这是基于先前示例的演示: http : //webix.com/snippet/14cbbeec

A dirty solution is to addDrop to webix widget $view property (= DOM Element): 肮脏的解决方案是将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);
  }
});

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

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

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