Custom traits value is not set in Code
Question
Hello,
Here I used textbox trailt and whatever I write in input box I got the text in Code Viewer. As you can see progress= 80

But when I create Custom traits and select value from dropdown then I didn't get any value in my Code(HTML).

Answers (3)
@HarshOB show how you create the custom trait
Here is the code:
editor.TraitManager.addType('customConent1', {
getInputEl: function () {
if (!this.inputEl) {
var input = document.createElement('select');
input.setAttribute("id", "Div1");
input.setAttribute("name", "Div1");
input.setAttribute("style", "background:#363636");
$.each(partialOptions, function (key, value) { //partialOptions is an array
var group = $('<optgroup label="' + key + '" />');
$.each(value, function () {
$('<option />').html(this.name).appendTo(group);
});
group.appendTo(input);
});
input.value = this.target.get('customConent1');
this.inputEl = input;
}
return this.inputEl;
},
});
@HarshOB try to see if the change actually triggers
editor.TraitManager.addType('customConent1', {
events:{
'change': 'onChange'
},
onChange() {
console.log('changed');
this.model.set('value', this.getInputEl().value);
},
getInputEl: function () {
...
Related Questions and Answers
Continue research with similar issue discussions.
Issue #417
Add Setting button to custom component.
Hello, How can I create a setting or you can say edit button for my custom component? LIke 4th option on this image:
Issue #1706
[Question]: How to get href from rte?
I have this rte toolbar where you can type and click 'save' and it's going to create a link for the selected text. but the problem is that...
Issue #1828
[Question] Add an additional text box for image upload modal?
Hi Artur, I'm wondering if that's possible to add some input boxes for image upload modal? I'd like to add some boxes in the red area in th...
Issue #1723
[QUESTION] replacing particular text in dropped component
Hi, I get the value from custom traits from what I entered but I don't know how to change the particular value in dropped component and ren...
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.