[QUESTION] Reset trait on edit the content of a custom component
See original GitHub issueHi,
I have a custom component which content can be changed by switching trait select options, but also can be edited similar to the text component type when it is already rendered inside the canvas. Is there an easy way to reset the traits related attribute on edit of a component?
model: {
defaults: {
type: 'tag',
tagName: 'span',
droppable: 0,
editable: 1,
textable: 1,
traits: [{
type: 'select',
label: 'Custom type',
name: 'customType',
options: customTypeOptions,
}],
},
toHTML() {
return this.get('content');
},
view: {
events: {
focus: 'resetTrait',
},
reseTrait() {
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How to Define Custom Traits on Grapes-js and How to ...
I am trying to do changing the position of the components by selecting the option on traits like if I Select traits to...
Read more >Saving a custom component with new name resets the dialog ...
Question : I saved a custom component with new name and the dialog contents was reset, why? Answer: This happens because of the...
Read more >Trait Manager - GrapesJS
Add Traits to Components · Built-in trait types. Text; Number; Checkbox; Select; Color; Button · Updating traits at run-time · Define new Trait...
Read more >Quotas - Qualtrics
You can also automatically reset your quotas after a certain amount of time. ... This menu gives you the same options available in...
Read more >Analytics.js 2.0 Source | Segment Documentation
By default, Analytics.js caches traits in the browser's ... Note: This must be an element, not a CSS selector. ... analytics.reset();.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@artf, regarding the “Select” I couldn’t manage to connect the change in the content and make it work on change of the trait in one flow and also to change it manually by editing it’s text/content. The manual change wasn’t syncing the trait, but I managed to make it work. A custom text component worked just fine.
As for the documentation from the last release, I am reading it right now and it looks very good, but I haven’t seen it when I posted the question.
It may be only me, but I learn by example, so more examples and use cases will be always a plus.
I understand that the product is open and I appreciate your effort. I hope that I will gain more knowledge and will be able to contribute with something in near future.
Cheers.
@inaLar I didn’t get the problem here
In the last release, I rewrote the Trait documentation from scratch (and added new API for customization) by trying to cover all the possible needs requested so far by GrapesJS users (doing the same right now for Components). Obviously, I can’t cover all cases for all the people but if you have any suggestion are more than welcome