Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
var getCTNode = function( domElement ) {
// Go through all the editable regions of CT
var regions = ContentTools.EditorApp.get().regions();
for ( var i in regions ) {
// Go through all the children / Element Nodes
var children = regions[ i ].children;
for ( var k in children ) {
if ( children[ k ]._domElement == domElement ) {
return children[ k ];
return null;

This comment has been minimized.

Copy link

commented Oct 9, 2015

So my recommendation would be this code instead:

ContentEdit.Root.get().bind('mount', function (element) {
    // Map the element to it's DOM element
    element.domElement()._ceElement = element;

This code stores are reference to the ContentEdit element whenever its mounted into the DOM against the DOM element it's mounted as. This way you can just use the domElement._ceElement attribute to find the element you're after. This should be a pretty efficient mechanism.


This comment has been minimized.

Copy link
Owner Author

commented Oct 10, 2015

Thanks I ended up ditching the whole thing for your suggestion :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.