Last active
December 20, 2015 20:38
-
-
Save GantMan/6191278 to your computer and use it in GitHub Desktop.
Gist for a blog article - http://iconoclastlabs.com/cms/blog/posts/a-clear-win-of-angularjs-over-jquery-example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-app ng-controller="Controller"> | |
<input ng-model="myCheck" type="checkbox" /> | |
<input ng-show="myCheck" type="text"> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Controller ($scope) { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$("#allow_max_members").each(function(box) { | |
var shown; | |
shown = $(this).prop('checked'); | |
$("#max_members").toggle(shown); | |
}); | |
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<input type="checkbox" data-hide="#max_members" /> | |
<input id="max_members" type="text" /> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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