Issue #996Opened April 3, 2018by HarshOB1 reactions

[QUESTIONS] change attribute value that is generated through trait

Question

Now, let's consider that I wrote new into the trait value but in attribute :items, I want to append prefix like item.text. to that value So, my final attribute :items become item.text.new. Is that possible?

screenshot from 2018-04-03 12-52-00

Answers (3)

artfApril 14, 20181 reactions

I'd say it's enough just this

getValueForTarget: function() {
    return 'item.text' + this.model.get('value');
  }
HarshOBApril 12, 20180 reactions

I tried creating custom trait and override a method but didn't see any attribute generated. can you please look at this code and correct me if there's any error. When I write data in traits it should generate attribute as ':text=item.text.data' at datatextfield.

 getInputEl: function() {
    if (!this.inputEl) {
      var input = document.createElement('textarea');
      input.value = this.target.get('content');
      this.inputEl = input;
    }
    return this.inputEl;
  },

  /**
   * Triggered when the value of the model is changed
   */
  onValueChange: function () {
    this.target.set('content', this.model.get('value'));
  },
  
  getValueForTarget: function() {
      console.log("inside getValueForTargetss")
    return this.model.get( 'item.text' + 'value');
  }
});

screenshot from 2018-04-12 10-21-21

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.