Amarillo Amarillo - 15 days ago 5
HTML Question

How to add a drop area to the text input?

I'm trying to implement DnD from the datatable to the Webix text input.
Actually, I found a sample for an html input:

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? is it possible to replace the DIV id with something?
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. Any ideas are appreciated.

Here's a demo based on the previous sample: http://webix.com/snippet/14cbbeec

Answer

A dirty solution is to addDrop to webix widget $view property (= DOM Element):

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