Issue #2333Opened October 16, 2019by Ramkumar-Murugesan1 reactions

can't able to remove the added traits properties[QUESTION]

Question

Hi, I can able to add the traits properties dynamically by using the following code.

 this.get('traits').add({
             type: 'text',
             label: 'entity',
             name: 'type',
             changeProp: 1
           }, { at: 2 });

but the following code to remove the type name is not working

this.get('traits').remove('type');

my complete traits are

comps.addType('link', {
      model: defaultModel.extend({
        defaults: Object.assign({}, defaultModel.prototype.defaults, {
          draggable: '*',
          droppable: false,
          traits: [{
            label: 'Name',
            name: 'name',
            type: 'text',
            changeProp: 1
          }, {
            type: 'checkbox',
            label: 'isDynamic',
            name: 'linkCheckboxModal',
            changeProp: 1
          }, {
            type: 'linkButton',
            label: 'Link',
            name: 'linkButton'
          }],

        }),
        init() {
          this.listenTo(this, 'change:linkCheckboxModal', this.dynamicModal);
        },
        dynamicModal() {
         this.changed['linkCheckboxModal']);
          if (this.changed['linkCheckboxModal']) {
            const component = screenGlobalVariable.editor.getSelected();
            this.get('traits').add({
              type: 'text',
              label: 'entity',
              name: 'type',
              changeProp: 1
            }, { at: 2 });
            screenGlobalVariable.editor.TraitManager.getTraitsViewer().render();
          } else {
            this.get('traits').remove('type');
            screenGlobalVariable.editor.TraitManager.getTraitsViewer().render();
          }
        }
        },
        {
          isComponent: function (el) {
            if (el.tagName === 'A') {
              return { type: 'link' };
            }
          },
        }),

      // Define the View
      view: defaultType.view,
    });

can anyone please help me

Answers (2)

pouyamiralayiOctober 16, 20191 reactions

Hi there! provide an id for your trait and try again based on this: this.removeTrait('trait-id'); cheers!

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.