Change 2 attributes with 1 trait
You should change the model and not the view element this.model.setAttributes({ 'data-attr': 'value' })
Read full answer below ↓Question
I have an input trait, I want to change the 2 attributes (name and type) on the selected input element, on canvas is appropriate, but in the final html(editor.getHtml()) it doesn't work, I've read https://grapesjs.com/docs/modules/Components.html#define-new-component but I didn't find a solution, Thank's

Answers (2)
You should change the model and not the view element this.model.setAttributes({ 'data-attr': 'value' })
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 #792
Script property using function don't work with blocks
In Components & JS docs there's this example: This works perfectly. But I couldn't use a function instead of a string in script, as is said...
Issue #686
Trait view doesn't update input element when target value changes
If the target value (i.e. Component attribute/prop) is set manually and not via the trait input element, the input doesn't reflect that cha...
Issue #1113
[QUESTIONS] New trait type is not working with rendered components?
Hello, thanks for the great framework. I'm trying to apply this to my project. I want to add a new trait for existing LINK '<a>' component....
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Related tutorials
In-depth guides on the same topic.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.