How to update the trait value
@abzal0 alright! although the prop approach must work fine, i am not sure why it is not, or i am missing something here! if we want to go with attributes, you must use `addAttributes` for changing the attribute, here is a working example of the procedure: Cheers!
Read full answer below βQuestion
Hello @artf thanks a lot for a great project, I have created a new type, it is similar to regular link, but the link title updates with ajax. Then updates the trait 'linktitle'. The value of it and the canvas do update, but the trait inside "Settings" still shows the initial value and does not changes. Part of the code that must update the value: editor.DomComponents.addType('newLink', { model: { defaults: { components: [ { highlightable: true, editable: true, selectable: true }], traits: [ { type: 'text', label: 'Url', name: 'url', value: 'https://', changeProp: 0 }, { type: 'text', label: '...
Answers (3)
@abzal0 alright! although the prop approach must work fine, i am not sure why it is not, or i am missing something here! if we want to go with attributes, you must use `addAttributes` for changing the attribute, here is a working example of the procedure: Cheers!
@pouyamiralayi thanks a lot for your time, this solved the issue:
this.model.addAttributes({'linkTitle':oldValue + ' Changed!'})
you saved so much time, thanks again :)
editor.getSelected().getTrait('linktitle').set('value','CCC');
does not works too
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1113
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....
Issue #1679
How to render component in canvas using trait.
Hi Artf ,Thanks for your great tool,I have created test case for my problem https://js.do/code/271771 I have created custom tool sidebar an...
Issue #3328
How can I update the nodeValue (text value) of components by inputs forms
Hello. Grapesjs is a great tool. Thanks for it. I want to update the text value of a component by inputs, how can I do that?? if a user fil...
Issue #2972
Disable scripts on canvas
Hello, first of all thanks for a great tool. On my project i hit the problem where I need to disable scripts inside the editor. I found 2 s...
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.
Tutorial
Messaging on gjs.market: talk to a studio before you buy, not after
We've launched private messaging between buyers and studios. One thread per buyerβstudio pair, the whole history in one place.
Tutorial
Vanilla GrapesJS vs GrapesJS With Plugins: What You Actually Get Out of the Box (2026)
New to GrapesJS? See exactly what the stock editor gives you, where it falls short, and which plugins close the gaps β a beginner-friendly 2026 comparison
Tutorial
Lighthouse for GrapesJS: Audit Accessibility and SEO Without Leaving the Editor
Live WCAG 2.1/2.2 accessibility auditor + SEO manager for GrapesJS. Every finding is bound to the exact component β click to select, then one-click fix.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.