Issue #1658πŸ’¬ AnsweredOpened December 13, 2018by christopherserrao050 reactions

Checkbox trait does not load as checked even when the trait value is true

Quick answerby artf

Update your grapesjs versionThe trait reads the value from the component, so place the initial value at the component level, not at the trait one

Read full answer below ↓

Question

Hi, I'm using Grapesjs version 0.14.33. I'm loading some components when the form loads and I have a component with a checkbox trait. When I load the component using editor.DomComponents.load, I'm loading the checkbox with the value true, which means that the trait should be rendered with the checkbox already checked. This is not working. However, when I check the trait value from the DOM object using the editor.getComponents().models[0].get('traits').models[0].get('value'), it returns true. Browser Used for Testing : Chrome v 69.0.3497.100 Actual Behaviour : The checkbox trait does not rende...

Answers (3)

artfβ€’ December 14, 2018
  1. Update your grapesjs version
  2. The trait reads the value from the component, so place the initial value at the component level, not at the trait one
christopherserrao05β€’ December 17, 2018

Hi Artf,

Thanks for your reply. Can you please provide me a sample link, or if you could please update the jsfiddle, to explain what you mean by "place the initial value at the component level".

Thanks

artfβ€’ December 20, 2018

I mean, when you add the checkbox element, put checked there <input data-gjs-editable="false" .... type="checkbox" ... checked/>

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.