[Question] Firing events with custom components
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 attribute is changing through print statements in the console. Any advice? I would also really like to know if there is any way to detect the change in the custom attribute from the index.html file script, after initializing the editor (in a setup similar to the Grapesjs newsletter and webpage plugins)? Thank you.
Just for tests purposes, try to listen all changes on your model.
try with this.listenTo(model, 'change') and see what you get.
@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' }))
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.