[QUESTION] any other way to listen the traits option changes
Question
HI, I added the code of listening to the changes made when the user selects the values in the dropdown. but I need to listen to the changes in some other places in the code.
comps.addType('input', {
model: defaultModel.extend({
defaults: Object.assign({}, defaultModel.prototype.defaults, {
draggable: '*',
droppable: false,
traits: [
{ name: 'name', label: 'Name' },
{ name: 'placeholder', label: 'Placeholder' },
{
label: 'Type',
type: 'select',
name: 'mytype',
changeProp: 1,
options: [{ value: 'text', name: 'Text' },
{ value: 'email', name: 'Email' },
{ value: 'password', name: 'Password' },
{ value: 'number', name: 'Number' }]
},
{ type: 'checkbox', name: 'required', label: 'Required' }
]
}),
init() {
this.listenTo(this, 'change:mytype', this.mytype);
},
mytype() {
alert('entity called');
}
},
{
isComponent: function (el) {
console.log('ram iscomponent for radio tagname and ttype', el.tagName, ' --- ', el);
if (el.tagName === 'INPUT') {
return {
type: 'input'
};
}
},
}),
// Define the View
view: defaultType.view,
});
In the above change working fine. but I need to listen to the changes in another place.

can anyone please help me
Answers (2)
You can make use of a global listener editor.on('component:update:mytype', ...) or trigger some custom event inside the local method
...
init() {
this.listenTo(this, 'change:mytype', this.mytype);
},
mytype() {
alert('entity called');
editor.trigger('YourEvent', { mytype: this.get('mytype') });
}
...
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Related Questions and Answers
Continue research with similar issue discussions.
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...
Issue #1995
[QUESTION] Binded events are not being loaded (Just work properly on mozilla firefox)
So I am using local Storage. I added some events to the component this way. Every time I add the component it works just fine. However, If...
Issue #709
isComponent is not returning trait
Happy new year! I am having an issue with isComponent(). Here is my code: For some reason the only time the trait shows up in component set...
Issue #845
Impossible to select Iframe
I've created a new type of component an general iframe, avoiding selecting the map, but when I try to select it in canvas so that the setti...
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.