I have a div
which instantiates an ace editor object.
I am trying to drag and drop
some text into it from an HTML draggable
.
I have made the ui-ace div droppable
and want to get the current instance of the editor from the event target of drop.
How can I accomplish this???
HTML
<div id="id1" ui-ace droppable=true ondrop="handleDrop(event,this)"></div>
JS function
function handleDrop(e,obj){
// need code to get current editor instance from obj without using ace.edit(obj.id)
// because ace.edit(obj.id) will reset the content I believe. Please correct me if I am
//wrong. Ace api says it will insert editor in the DOM. ;api=ace
}
Please help.
I have a div
which instantiates an ace editor object.
I am trying to drag and drop
some text into it from an HTML draggable
.
I have made the ui-ace div droppable
and want to get the current instance of the editor from the event target of drop.
How can I accomplish this???
HTML
<div id="id1" ui-ace droppable=true ondrop="handleDrop(event,this)"></div>
JS function
function handleDrop(e,obj){
// need code to get current editor instance from obj without using ace.edit(obj.id)
// because ace.edit(obj.id) will reset the content I believe. Please correct me if I am
//wrong. Ace api says it will insert editor in the DOM. http://ace.c9.io/#nav=api&api=ace
}
Please help.
Share Improve this question edited Aug 22, 2014 at 17:28 Darshan Patel 2,8992 gold badges26 silver badges39 bronze badges asked Aug 22, 2014 at 17:12 user3779089user3779089 4192 gold badges6 silver badges13 bronze badges1 Answer
Reset to default 25I don't know why this is not mentioned in the API documentation, but if you call ace.edit
on an already instantiated editor, you will get that instance. It will NOT reset that editor. I have tested it.
In your case, it could be accomplished by the following code:
function handleDrop(e,obj)
{
var editor = ace.edit(obj.id);
// Do something with editor
}
I know it has been a while since you have asked this question, but I couldn't find anything on this topic so I thought I should share this.