Skip to content

Instantly share code, notes, and snippets.

@GantMan
Last active December 20, 2015 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save GantMan/6191278 to your computer and use it in GitHub Desktop.
Save GantMan/6191278 to your computer and use it in GitHub Desktop.
<div ng-app ng-controller="Controller">
<input ng-model="myCheck" type="checkbox" />
<input ng-show="myCheck" type="text">
</div>
function Controller ($scope) {
}
# lagniappe coffeescript version for you
(($) ->
# show if it is checked
$("input[data-hide]").each (box) ->
shown = $(@).prop('checked')
$($(@).data('hide')).toggle(shown)
# On change, toggle visibility
$("input[data-hide]").change ->
to_hide = $(@).data('hide')
$(to_hide).fadeToggle()
) jQuery
(function($) {
$("#allow_max_members").each(function(box) {
var shown;
shown = $(this).prop('checked');
$("#max_members").toggle(shown);
});
})(jQuery);
<div>
<input type="checkbox" data-hide="#max_members" />
<input id="max_members" type="text" />
</div>
(function($) {
$("input[data-hide]").each(function(box) {
var shown;
shown = $(this).prop('checked');
return $($(this).data('hide')).toggle(shown);
});
return $("input[data-hide]").change(function() {
var to_hide;
to_hide = $(this).data('hide');
return $(to_hide).fadeToggle();
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment