I often create components that need to return some result to the parent
component. Couple of approaches I have done:
- Pass an object to the sub component and have that sub
component modify the object directly, I am not really fond of this
approach, I don't want sub components modifying the state of my objects.
- Have the component trigger DOM events, this works well, but it
always feels like it is more work than was is needed.
Another approach that I would like to use is to simply pass a
callback function to the sub component. I have seen React using this method:
<FundooRating value={this.state.rating} max="10" onRatingSelected={this.handleRatingSelected} />I'm trying to replicate this in CanJS, but can't make it work yet. Please see this fiddleIs it possible? What I'm missing?