How to get Ace Editor object from your Div id

I have a div that instantiates an ace editor object.

I am trying to drag and drop add text from HTML draggable .

I made a ui-ace div droppable and want to get the current editor instance from the drop event object.

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.

+8
javascript html
source share
1 answer

I do not know why this is not mentioned in the API documentation, but if you call ace.edit in an already created editor, you will get this instance. This will NOT reset this editor. I tested it.

In your case, this can be done using the following code:

 function handleDrop(e,obj) { var editor = ace.edit(obj.id); // Do something with editor } 

I know that some time has passed since you asked this question, but I could not find anything on this topic, so I decided to share this.

+16
source share

All Articles