Issue #1095💬 AnsweredOpened May 8, 2018by Chilli-B0 reactions

Preselect a trait select option

Quick answerby artf

Hi @Chilli-B it would be better if you provide a live example of what you're trying to accomplish. BTW, if the trait is correctly created it should be synced with the component model, for example:

Read full answer below ↓

Question

Hello, I'd like you to add to the options array of a select trait a third parameter next to 'name' and 'value', which is 'selected' in order to pre-select one of the trait options. In detail: I extended the header component by a select trait for all header types h1 through h6. Now I'd like to add something to the event function 'component:selected' so that when the component is clicked, the trait select for the header type is directly switching to the fitting option as far as a header tag is included (for example h2 tag is clicked => 2nd select option is pre-selected) I was wondering if there...

Answers (3)

artfMay 10, 2018

Hi @Chilli-B it would be better if you provide a live example of what you're trying to accomplish. BTW, if the trait is correctly created it should be synced with the component model, for example:

Chilli-BMay 10, 2018

Hi @artf , thanks for your reply. Below is how I created the trait by extending the text model for the header component. The problem is not the syncronization. The problem is, when I'm adding complete layouts to the canvas, which are including h2 or h3 tags (or any others), and I'm clicking on them...

artfMay 14, 2018

The problem is not the synchronization. The problem is, when I'm adding complete layouts to the canvas, which are including h2 or h3 tags (or any others), and I'm clicking on them, the header type select in the settings (traits) always stays at "Headline 1", as this is the first option in the selec...

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.