How to Update Style from checkbox Trait?
Question
Hi @artf I am trying to update the style using the checkbox trait but it's not calling the function. Here is the code
editor.DomComponents.addType('grid-item', {
model: {
center: false,
defaults: {
traits:[
...editor.Components.getType('default').model.prototype.defaults.traits,
...[
{
name: 'center',
label: 'Center content',
type: 'checkbox',
changeProp: 1,
}
]
]
},
},
view: {
init(){
// this.listenTo(this, 'change:center', this.updatestyle);
this.on("change:center", this.updatestyle);
},
updatestyle(){
const b = this.model.get('center');
console.log(b);
this.addStyle({'justify-content':'center'});
}
}
});
I really appreciate any insight that you can provide! Thanks
Answers (1)
@artf Got it silly-Mistake move the init function in the model itself. Closing the issue
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2337
[BUG / QUESTION] Deleting default styles does not work
Hello, i'm trying to delete some of the default styles of the blocks. I wrote everything I changed in a plugin. I used this function to upd...
Issue #3237
Add Trait For wrapper
Hi @artf I've added trait for wrapper this way. How can I perform the init function for the same Here is the code @artf Could you please he...
Issue #2456
[QUESTION] (Possibly a bug) How to apply traits to components used for GrapesJs initialization
I am using This works but only for blocks which are added/drag-dropped to the editor manually after it is initialized. If we supply compone...
Issue #2212
Extending default image component, resizable properties ignored
I'm trying to extend the default image component. I can see my "Test" trait, so I assume that the component is correctly overridden, but th...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.