Saturday, February 11, 2012


I'm writing this post just to share an interesting conversation that popped up on #sproutcore this week. Sproutcore is a huge framework and there is no amount of documentation that will explain it all, that's why I suggest you hang out in IRC. Even if you don't have questions to ask you'll learn a lot from others'.

In this case the question was: how do I make my custom view update whenever one of the content object properties change?
The perfect case for this, I think, would be if we were writing a custom SC.ListItemView.

In my case, prior to discovering SC.ContentDisplay I used the following configuration in a custom ListItemView:

Maps.OpenLayersLayer = SC.View.extend({
content: null,
displayProperties: ["content", "content.order", "content.visible", "content.opacity", "content.cql_filter"],

While it works (it was, I quote, described as funny though) this is the recommended way to do it:

Maps.OpenLayersLayer = SC.View.extend(SC.ContentDisplay, {
content: null,
contentDisplayProperties: ["order", "visible", "opacity", "cql_filter"],

Thanks to jdooley who pointed to the solution.

No comments: