Issue #419Opened October 13, 2017by sanjeevSavitr0 reactions

Adding New Elements in commands

Question

Code SnippetTEXT
commands:{
			{
            id:   'sub_menu_item',
            run: function(editor, senderBtn){
                
                const comp = editor.getSelected();
                comp.view.el.querySelector('[data-js=submenu_container]').innerHTML += '<a class="navbar-menu-link">Sub Menu Item</a>';

            },
          },
	}

This can add **Sub Menu Item**  to the container. But I am unable to select it. I tried with AppendChild also. But the result is same. I should be able to edit the newly added component. Pls help me

Answers (2)

artfOctober 16, 20170 reactions

Read more about how components work You have to add components via model (eg. model.get('components').add('<div>...</div>')) if you want them to be selectable (you can't select elements without models). Like you did, it's just a static content for the editor

lock[bot]September 18, 20190 reactions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.