Skip to content

Instantly share code, notes, and snippets.

@lukes
Created August 6, 2014 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukes/3a668785760e9c818f4e to your computer and use it in GitHub Desktop.
Save lukes/3a668785760e9c818f4e to your computer and use it in GitHub Desktop.
Simplest Ember 5 Star Rating component
App.ApplicationController = Ember.ObjectController.extent
starRatingValue: Ember.computed(->
"3"
)
Value: {{starRatingValue}}
{{star-rating value=starRatingValue}}
{{#each star in stars}}
<span {{action 'setValue' star}}>
[{{star.selected}} {{star.index}}]
</span>
{{/each}}
App.StarRatingComponent = Ember.Component.extend
classNames: ['star-rating']
value: 0
stars: (->
[1..5].map (i) =>
Ember.Object.create({selected: (i<=parseInt(@get('value'))), index: i})
).property('value')
actions:
setValue: (star) ->
@set('value', star.index)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment