[QUESTION] replacing particular text in dropped component
Question
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 render into the canvas
my screenshot

what I really want is to replace the regular text value to which I have entered in custom traits u can see in my screenshot
my custom traits is
comps.addType('segment-type', {
model: defaultModel.extend({
// Extend default properties
defaults: Object.assign({}, defaultModel.prototype.defaults, {
// Can be dropped only inside `form` elements
draggable: '*',
// Can't drop other elements inside it
droppable: true,
// Traits (Settings)
traits: [{
type: 'text',
label: 'segmentButton1',
placeholder: 'Regular',
name: 'segmentButton1',
changeProp: 1
}, {
type: 'text',
label: 'segmentButton2',
placeholder: 'Urgent',
name: 'segmentButton2',
changeProp: 1
}],
}),
toHTML: function() {
},
init() {
this.listenTo(this, 'change:segmentButton1', this.firstButton);
this.listenTo(this, 'change:segmentButton2', this.secondButton);
},
firstButton() {
//do something
var segmentButton = document.getElementsByTagName('ion-segment-button');
btn1 = segmentButton[segmentButton.length - 2];
},
secondButton() {
var segmentButton = document.getElementsByTagName('ion-segment-button');
btn2 = segmentButton[segmentButton.length - 1];
},
}, {
isComponent: function (el) {
if (el.tagName == 'ion-segment') {
return {
type: 'segment-type'
};
}
},
}),
// Define the View
view: defaultType.view,
});
here I try to get dropped element but it shows undefined. Can u please help me
Thanks.
Answers (2)
firstButton() {
const component = this.find('ion-segment-button')[0];
// eg. update inner component contents
component.components('<div>New content</div>')
},
Please check the Component API
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 #408
How to update toolbar of component?
Hi Artf, i was added new command to editable component, update style work well but i don't know how to update this toolbar after component...
Issue #794
[QUESTION] How to create a custom option in toolbox?
I would like to know how can I create a custom "option" with custom content in this place:
Issue #1869
[QUESTION] how to add extra field in input traits
Hi, I want to add the new field in default input traits. for example:- i need to add {label: binding, name:binding} in already exist input...
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...
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.