question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New Trait creation. The value is not set?

See original GitHub issue

I am trying to create a new Trait for a component. The textarea appears but it is not saving when trying to edit back, and the object has no “content” attribute. Why? I am basically using the code from here: https://github.com/artf/grapesjs/wiki/Traits#define-new-trait-type

// Each new type extends the default Trait
editor.TraitManager.addType('content', {
  events:{
    'keyup': 'onChange',  // trigger parent onChange method on keyup
  },

  /**
  * Returns the input element
  * @return {HTMLElement}
  */
  getInputEl: function() {
    var selectedModel = this.target;
    var input = document.createElement('textarea');
    input.value = selectedModel.get('content');
    return input;
  },

  /**
   * Triggered when the value of the model is changed
   */
  onValueChange: function () {
    this.target.set('content', this.model.get('value'));
  }
});

Thank you!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
artfcommented, Oct 5, 2017

done

1reaction
NETCreator-UScommented, Aug 9, 2017

Thank you, @artf ! It works now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Defining Traits: Initialization and Validation
method : The default value is created by calling a method on the object the trait is bound to; the default attribute returns...
Read more >
How to fix value is not a member of specific trait with instance ...
The problem is that observer is of type Observer which doesn't have any method updated defined, thus it fails. You may refine the...
Read more >
Error while creating new trait from Signals Dashboard
Description. While creating a new traits from signals present in Signals Dashboard, I am getting below error: Signal that I am trying to...
Read more >
SQL Traits | Segment Documentation
From the Audiences viewer, go to the Computed Traits tab, and click New Computed Trait. Next, choose SQL, and click Configure.
Read more >
Trait Types — traitlets 5.8.0 documentation
Create a List trait type from a list, set, or tuple. The default value is created by doing list(default_value) , which creates a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found