QUESTIONS : Find element in Model
https://github.com/artf/grapesjs/issues/1157#issuecomment-397104559
Read full answer below ↓Question
I have custom component and it render below html, I want to update value of h4 tilte and other element on trait changed, but not sure how can I find h4 and other element in model (NOT in view) and change value via trait change. I have used below approach but does not want to access model via index. updateTitle : function updateTitle() { var title = this.get('title'); var linkModel = this.get("components").at(0); if (linkModel) { var titleContainer = linkModel.get("components").at(3); if (titleContainer) { var h4 = titleContainer.get("components").at(0); if (h4) { h4.set("content", title); } }...
Answers (2)
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 #1424
Checkbox trait value is rendered differently in view (render()) vs model (getHtml())
I have a custom component with a checkbox trait 'show-name'. When the trait value is 'true', the component renders in the view to the attri...
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 #1157
Return span randomly in custom component
I have custom component and on trait change wanted to updated html but randomly it returned span/textnode in trait change function insted o...
Issue #513
Model and returned html issue
I have below code to create custom component and wants to retrieve updated html via editor.html() but return wrong html, I am sure I am mis...
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.