Skip to content

Commit

Permalink
Split visible binding.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbest committed Aug 29, 2012
2 parents 355301f + 3661fd3 commit a7eb425
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/binding/defaultBindings/visibleBinding.js
@@ -0,0 +1,10 @@
ko.bindingHandlers['visible'] = {
'update': function (element, valueAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor());
var isCurrentlyVisible = !(element.style.display == "none");
if (value && !isCurrentlyVisible)
element.style.display = "";
else if ((!value) && isCurrentlyVisible)
element.style.display = "none";
}
};

0 comments on commit a7eb425

Please sign in to comment.