Last active
December 15, 2015 06:49
-
-
Save tleite/5219073 to your computer and use it in GitHub Desktop.
This is a way to bind Bootstrap's accordion behavior directly in the view
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
<script> | |
ko.bindingHandlers.collapseAccordion = { | |
init: function(element, valueAccessor, allBindingsAccessor, viewModel) { | |
if($(element).hasClass("collapse")){ | |
$(element).removeClass("collapse").attr().addClass("in"); | |
} else { | |
$(element).removeClass("in").addClass("collapse").attr("style","height:0px"); | |
} | |
} | |
} | |
</script> | |
<div data-bind="collapseAccordion: conditionalStatement" class="accordion-body"> | |
... | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment