Skip to content

Instantly share code, notes, and snippets.

@Will-Sommers
Created August 13, 2013 20:36
Show Gist options
  • Save Will-Sommers/6225434 to your computer and use it in GitHub Desktop.
Save Will-Sommers/6225434 to your computer and use it in GitHub Desktop.
$('#transaction_recipient').on 'change', ->
switch $(this).val()
when 'artist' then hide_and_slide('artist')
when 'venue' then hide_and_slide('venue')
when 'affiliate' then hide_and_slide('affiliate')
else hide_and_slide('setfm')
hide_and_slide = (display_field) ->
show_id = "##{display_field}-token-selection"
$(show_id).slideDown()
field_tags = []
fields = ['artist', 'venue', 'affiliate']
for field in fields when field isnt display_field
field_tags.push("##{field}-token-selection")
$(".#{field}-tokens-input").tokenInput('clear') if $(".#{field}-tokens-input").length > 0
$(field_tags.join(', ')).slideUp()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment