Skip to content

Instantly share code, notes, and snippets.

@cohitre
Forked from joevandyk/gist:1337909
Created November 3, 2011 22:01
Show Gist options
  • Save cohitre/1337920 to your computer and use it in GitHub Desktop.
Save cohitre/1337920 to your computer and use it in GitHub Desktop.
Tanga.initialize '#upsell', ->
select = $('#upsell select')
notice = $('#upsell p.notice')
// more readable checkbox selector
checkbox = $('#upsell :checkbox')
callback = ->
// Let's only check the value of $(this), easier to debug if there is more than one checkbox.
notice.toggle $(this).is(":checked")
// select is a jQuery element, use jQuery methods to disable it.
if $(this).is(":checked")
select.attr("disabled", 'disabled')
else
select.removeAttr("disabled")
true
// removing this, the value gets set when you trigger the change() event
// select.disabled = true
// bind the callback and trigger it.
checkbox.change(callback).change()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment