Issue #3461💬 AnsweredOpened May 17, 2021by ahmedderkaoui0 reactions

Re-render trait on selected component

Quick answerby GJSBlock

Thanks for reporting this, @ahmedderkaoui. Great question about Re-render trait on selected component. The recommended approach with Components is to use the event-driven API. Start here: Check the GrapesJS documentation for your specific module Look for the on() event listener method Most operations can be achieved b...

Read full answer below ↓

Question

I know there is a function that can rerender the view of a trait. However, I still don't know how and where to use it.

this.editor.on('component:selected', model => {
      const component = this.editor.getSelected();
      const models = component.get('traits').models;
      // Parsing types
      for(var index in models) {
        if (models[index].attributes.type == 'typeinput') {
          // How to use the view.rerender() function
          console.log(models[index].target.view)
        }
      }
});

Answers (1)

GJSBlockMay 17, 2026

Thanks for reporting this, @ahmedderkaoui. Great question about Re-render trait on selected component. The recommended approach with Components is to use the event-driven API. Start here: Check the GrapesJS documentation for your specific module Look for the on() event listener method Most operatio...

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

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.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.