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.
Getting/Setting Values: var code = editor. getValue(); editor. setValue("new code here");
I 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With