Issue #2106💬 AnsweredOpened June 29, 2019by alialrabi0 reactions

Traits not appear in edit mode when i update grapes version

快速解答by artf

@alialrabi How do you define traits? Inside blocks or custom components?

Read full answer below ↓

Question

Hi artf, i make traits for specific component ,when i saved this component as a json and load again in editor the traits were load correctly and there is no proplem , when i update version of grapesjs traits appear only in first time , when load component again default trait was exist , how can i load traits again , and appear it in edit mode ?

Answers (3)

artfJuly 11, 2019

@alialrabi How do you define traits? Inside blocks or custom components?

alialrabiJuly 14, 2019
代码片段TEXT
@artf  i have created traits in custom component  like this 

      domComps.addType('assetType', {
            model: dModel.extend(
                {
                    init() {
                        this.listenTo(this, 'change:type', this.doStuff);
                    },
                    doStuff() {       
                    },
                    defaults: Object.assign({}, dModel.prototype.defaults, {
                        traits: [
                            {
                                name: 'button',
                                label: 'Add',
                                type: 'buttonModal',
                                changeProp: 1

                            },
                            {
                                type: 'select',
                                label: 'Page',
                                name: 'type',
                                options: this.pagesList,
                                changeProp: 1,
                            },
                        ],
                    }),
                },

                {
                    isComponent: function (el) {
                        if (el.tagName == 'div') {
                            return { type: 'asset' };
                        }
                    },
                },
            ),

            view: dView,
        });
artfJuly 14, 2019

@alialrabi you're defining your component with a name assetType but then in isComponent the type is asset

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.