[QUESTION] Update component view on property change
See original GitHub issueHi everyone, I’m trying to create a component that will update it’s view based on a property value
editor.DomComponents.addType("price-value-type", {
isComponent: el => {
if (el.tagName == "div" && el.hasAttribute("price-value")) {
return { type: "price-value-type" };
}
},
model: {
defaults: Object.assign({}, defaultProperties, {
defaultPrice: 0,
name: "Price",
classes: ["price"],
components: model => {
return `${model.get("defaultPrice")}`}
})
},
extendView: 'default',
extendFnView: ['render'],
view: {
init() {
console.log(this.render);
this.listenTo(this.model, 'change:defaultPrice', this.render);
},
// render() {
// this.el.innerHTML = this.model.get("defaultPrice");
// }
}
});
My approach is bassed on #1227 and on the docs In my use case I don’t need the trait, I can just update the property programmatically. But this won’t work and will not display any component on the canvas even though they are on the layer manager as we can see here(they show properly with the render function commented) maybe i’m missing something?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
View doesn't update on component property change in ...
The problem I am having is that the bindings in the view don't seem to update the first time I call the service,...
Read more >LWC - Component not Rerendering when Property Changes
I assign the updated information to an array but the component does not rerender and therefore does not call a child component to...
Read more >How to Observe Property Changes with LitElement and ...
This method will be called when an element should be updated based on a component state or property change. It's a good place...
Read more >48 answers on StackOverflow to the most popular Angular ...
I'm writing an Angular component that has a property Mode(): string . I would like to be able to set this property programmatically...
Read more >Explore component properties - Figma Help Center
Component properties are the changeable aspects of a component. You can define which parts of a component others can change by tying them...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
to update the HTML you have to change
toHTML
in the modelI’ll give it a try the day after tomorrow. Thanks for your quick replies!