Skip to content

Instantly share code, notes, and snippets.

@STRd6
Created July 15, 2013 02:08
Show Gist options
  • Select an option

  • Save STRd6/5997051 to your computer and use it in GitHub Desktop.

Select an option

Save STRd6/5997051 to your computer and use it in GitHub Desktop.
tickets: [
{name: "None", price: null}
{name: "Economy", price: 199.95}
{name: "Business", price: 449.22}
{name: "First Class", price: 1199.99}
]
chosenTicket: Observable()
resetTicket: ->
@chosenTicket(@tickets[0])
#preview
font-family: helvetica
padding: 0.5em
Choose a ticket class:
%select
- on "change", @chosenTicket
- each @tickets, ->
%option= @name
%button Clear
- on "click", @resetTicket
- with @chosenTicket, ->
%p
- if @price
You have chosen
%b= @name
%span $#{@price}
- else
No ticket chosen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment