Issue #1030πŸ’¬ AnsweredOpened April 12, 2018by francesca-cicileo0 reactions

Firing events with custom components

Quick answerby arthuralmeidap

Just for tests purposes, try to listen all changes on your model. try with this.listenTo(model, 'change') and see what you get.

Read full answer below ↓

Question

I'm trying to build a plugin for Grapesjs with some custom components, and I'm having trouble with triggering events and interacting with the component in the code. One problem I am having is that I added an attribute to the model for a custom text component. In the script for that text component, I change the attribute if the user has typed a certain character in the component. In the view for the component, I have a listener for the attribute: this.listenTo(model, 'change:customAttribute', this.doSomething);. My issue is that doSomething is never called, even though I can see that the attri...

Answers (3)

arthuralmeidapβ€’ April 12, 2018

Just for tests purposes, try to listen all changes on your model.

try with this.listenTo(model, 'change') and see what you get.

artfβ€’ April 14, 2018

@francesca-cicileo 'change:*' is used for model's properties (eg. tagName, removable, etc.), probably you're looking for change:attributes:ATTR-NAME. Be sure to update model's properties properly (eg. model.addAttributes({ attrName: 'value' }))

lock[bot]β€’ September 17, 2019

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.

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.