Created
October 11, 2013 18:43
-
-
Save kaleb/6939906 to your computer and use it in GitHub Desktop.
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
.menu { | |
background-color:white; | |
border:1px solid red; | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/knockout/2.2.1/knockout-min.js"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="view"> | |
<button type="button" class="menu-toggle"> | |
Toggle Menu | |
</button> | |
<div class="menu-container"> | |
<ul data-bind="style: { display: expanded() ? 'block' : 'none'}" class="menu"> | |
<li>one</li> | |
<li>two</li> | |
<li>three</li> | |
</ul> | |
</div> | |
</div> | |
</body> | |
</html> |
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
ko.applyBindings({ | |
expanded: ko.observable(false) | |
}, view); | |
$('.menu-toggle').on('click', function () { | |
var expanded = ko.dataFor(this).expanded; | |
expanded(!expanded()); | |
}); | |
$('.menu').appendTo('body'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment