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)
Hi there! provide an id for your trait and try again based on this:
this.removeTrait('trait-id');
cheers!
Use addTrait and removeTrait methods
Related Questions and Answers
Continue research with similar issue discussions.
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 #2819
[Question] I am updating trait using addTrait function? It updates and adds the trait in trait manager but unable to reflect it in html section of codeManager?
I have written the following code - const component = editor.getSelected(); component.addTrait({ name: 'traitName', type: 'text', label: 't...
Issue #975
[Question] Default values for traits field
I have created component with certain traits. I am not able to assign default value to traits by passing values. It is coming as undefined...
Issue #1959
[Question] Edit innerHTML in a custom button
Hi All, I am trying to change the text in a button component, but I am not able to edit it. I added this type: I included the editable: tru...
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.