Issue #2597Opened February 24, 2020by ikenderham0 reactions

How to add custom name to allready inserted components?

Question

Hello..

I need to put af custom name on my components. I can do that by adding data-gjs-custom-name="myname" but how do i do that on allready inserted elements?

I tried to editor.SelectorManager.getAll().each(selector => $('h1').attr("data-gjs-custom-name","h1"));

but its not working. How is it possible to put a name on all h1, for example?

Answers (1)

artfMarch 1, 20200 reactions

I can do that by adding data-gjs-custom-name="myname"

Use name instead of custom-name (this one is used for Layers when you edit them), so data-gjs-name="myname"

How is it possible to put a name on all h1, for example?

You can create a custom component to extend the definition for H1 elements, so this will be applied to all H1 (even added lately) or you can do it interactively only on the components in the canvas in this way

editor.getWrapper().find('h1').forEach(
	component => component.set('name', 'Name H1')
)

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.