[Question] update Trait select option dynamically
Question
I tried this to update trait selection.
var updateTrait = function(id, name) {
var typeTrait = model.get('traits').where({name: 'type'})[0];
var options = typeTrait.get('options');
options.push({value: id, name: name});
typeTrait.set('options', options);
};
But after click the element, it shows this error and the trait doesn't update.
Answers (2)
Hey @boris1989529 I am also stuck at this point to update the traits dynamically even in scenario i also need to push the option into the once of my trait.
Did you got any solution for this? It would be your pleasure if you can share the solution for me if you found. Thanks in advance.
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 #1894
[BUG] Custom Trait documentation example doesn't work
Specifically this: https://grapesjs.com/docs/modules/Traits.html#define-new-trait-type First of all, the keyUp event references onChange wh...
Issue #413
Use trait to modify component class
Hi! I'm trying to change the value of the classes with very little succes. Here is my custom trait's onValueChange function: Which results...
Issue #1095
[FEATURE REQUEST] Preselect a trait select option
Hello, I'd like you to add to the options array of a select trait a third parameter next to 'name' and 'value', which is 'selected' in orde...
Issue #1702
[Question]How to get rte selection inside the result function
I'm basically trying to put an input fieldinside the RTE so that users can make link more easily. console.log(<a href="#">${rte.selection()...
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.