Issue #2106Opened June 29, 2019by alialrabi0 reactions

Traits not appear in edit mode when i update grapes version

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, 20190 reactions

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

alialrabiJuly 14, 20190 reactions
Code SnippetTEXT
@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, 20190 reactions

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

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.