Issue #3225Opened January 9, 2021by Abhisheknanda13444630 reactions

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)

Abhisheknanda1344463January 10, 20210 reactions

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

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.