Created
December 23, 2011 17:53
-
-
Save adamloving/1514920 to your computer and use it in GitHub Desktop.
Knockout binding handler using jQuery fadeIn and fadeOut
This file contains hidden or 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
| ko.bindingHandlers.fade = | |
| init: (element, valueAccessor) -> | |
| element = jQuery(element) | |
| value = valueAccessor() | |
| value = ko.utils.unwrapObservable() | |
| element.toggle(value) | |
| update: (element, valueAccessor) -> | |
| element = jQuery(element) | |
| value = valueAccessor() | |
| value = ko.utils.unwrapObservable(value) | |
| element.fadeIn() if value | |
| element.fadeOut() unless value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@collinwat and @harleyholt get credit for this, not me. I just think it is cool.