Issue #990Opened April 1, 2018by anand-gopinath0 reactions

How to listen an event for custom component's style update?

Question

@artf @arthuralmeidap @nojacko I have a custom component like, this and i the code looks like https://jsfiddle.net/nganand/n97g7g43/ .

bbb

  1. How to listen to an event when custom component's property changed (Ex, when styling padding/margin)? like init() { this.listenTo(this.model, "component:styleUpdate:text-align", this.handleChange) }

  2. I wish align the button to left, by selecting not parent. Instead by selecting the ancestor. So How to change the custom component's children view when parent selected ? I did something like this.model.attributes.components.models[0].attributes.attributes.align = "left" this.el.getElementsByClassName("mjmlButton")[0].align = "left"; this.render() But not worked?

Answers (2)

artfApril 4, 20180 reactions
  1. For component's properties use this.listenTo(this.model, "change:prop-name" ...
  2. By doing ...attributes.align = "left" Component doesn't see your changes, use instead this.model.components().at(0).addAttributes({ align: 'left' }), you don't need to update/render the element.
lock[bot]September 17, 20190 reactions

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.