Search code examples
javascriptlabelsproutcore

Sproutcore: Text not displayed in LabelView


The following is where LabelView is defined. Whatver is being is set as its value is also displayed in an alert box on clicking it. However only the alert box shows the output.:

    outputView: SC.LabelView.design({
          layout: { width: 500, height: 18 }, 
          valueBinding: SC.Binding.oneWay('Tree.categoriesControllerList.selection.content'),
          click: function(){ 
             alert(Tree.categoriesControllerList.getPath('selection.firstObject.content'))
          }})

The value of the label is not being set for some reason. The value given is viewUpdate, defined as follows:

viewUpdate: function(){         
          if (this.didChangeFor('selectionDidChange', selection')&&this.getPath('selection.firstObject.notes')==null){
                    return this.getPath('selection.firstObject.content')
            }
        }.property()

I'm certain that this is returning the right value because whenever I click on the label, its value appears in the alert box as instructed.

Where am I going wrong?


Solution

  • I think you just forget "firstObject" in the value binding:

    valueBinding: SC.Binding.oneWay('Tree.categoriesControllerList.selection.firstObject.content'),