Issue #1723Opened January 10, 2019by Ramkumar-Murugesan0 reactions

[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

image

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)

artfJanuary 14, 20190 reactions
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

lock[bot]January 15, 20200 reactions

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.

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.