O'Reilly logo

SproutCore Web Application Development by Tyler Keating

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Updating custom views

The next step in creating a functional custom view is to efficiently update the display when necessary. For instance, in the previous example, we would want to be sure about updating the display each time the value of name changes. To do this, we use the displayProperties array to name the properties that, when changed, should cause our view's display to update.

Therefore, here's an addition to MyApp.NameLabelView that will ensure our view updates each time the 'name' value changes:

MyApp.NameLabelView = SC.View.extend({

  displayProperties: ['name'],

  // ...

Tip

Each property named in displayProperties will be observed for changes. So, be sure to only list those properties that directly affect the rendering. Listing extra properties ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required