Closed cedriclinares closed 3 years ago
Hey Cedric,
Is it possible that you’re using version 2.0.0 of ember-set-helper? https://github.com/pzuraq/ember-set-helper/releases/tag/v2.0.0
In the book we use version 1.1.0 and I just double-checked that the code works fine with it.
If you do have 2.0.0, that explains the difference and I’ll have to update the examples that have {{set}} in them for the next release.
Could you confirm that?
Yes I have version 2.0.0. I'll switch over to 1.1.0!
I had the same issue with ember-set-helper v2.0.0. Using set
helper this way worked for me.
<StarRating
@rating={{song.rating}}
@onUpdate={{set song 'rating'}}
/>
@cedriclinares @fabmiz Thank you, I'll update the book for v2.0.0 for the next release.
I followed the instructions in the rarwe Octane book. Everything was working correctly until I tried to implement editing the song rating and I don't know what is wrong.
Here is star-rating.hbs:
{{#each this.stars as |star|}}
<button type="button" {{on "click" (fn @onUpdate star.rating)}}>
<FaIcon @icon="star" @prefix={{if star.full "fas" "far"}} />
</button>
{{/each}}
songs.hbs:
{{#if @model.length}}
<ul>
{{#each @model as |song|}}
<li class="mb-2">
{{song.title}}
<span class="float-right">
<StarRating @rating={{song.rating}} @onUpdate={{set song.rating}} />
</span>
</li>
{{/each}}
</ul>
{{else}}
<p class="text-center">
The band has no songs yet.
</p>
{{/if}}
The console gives me an error
When I click on a star nothing happens. I don't think the on click is being called because I tried to log a string and it would not print to the console. Please help!