Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. /**
  2. * Knockout Extension: Hidden
  3. *
  4. * The inverse of the `visible` binding: hides the element when the observable
  5. * is true, shows it when the observable is false.
  6. *
  7. * @requires Knockout.js
  8. * @requires jQuery
  9. * @author Jon Stout (www.jonstout.net)
  10. */
  11.  
  12. 'use strict';
  13.  
  14. (function(ko, $) {
  15.  
  16. if (typeof ko.bindingHandlers.hidden === 'undefined') {
  17.  
  18. ko.bindingHandlers.hidden = {
  19. update: function(element, valueAccessor) {
  20. var isHidden = ko.unwrap(valueAccessor());
  21. if (isHidden) {
  22. $(element).hide();
  23. } else {
  24. $(element).show();
  25. }
  26. }
  27. };
  28.  
  29. }
  30.  
  31. })(ko, jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement