Issue #1658Opened December 13, 2018by christopherserrao050 reactions

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

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 render as checked but the trait value in the DOM object is true.

Expected Behaviour : The checkbox trait should render as checked if the component is loaded with the trait value of true.

JS Fiddle link to reproduce the issue : https://jsfiddle.net/g3zh12r7/4/

Thanks

Answers (3)

artfDecember 14, 20180 reactions
  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
christopherserrao05December 17, 20180 reactions

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

artfDecember 20, 20180 reactions

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

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.