semantic-ko
semantic-ko copied to clipboard
KO vs SKO compatibility question
Hi Antonio,
The SemanticKO docs describe it as being "built on top of" or "a fork of" of Knockout, which leaves me unsure whether I should expect all Knockout features to work? For example,
This (derived from Knockout docs on binding contexts) works with KO:
<head>
<title>knockout testing</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/knockout/2.1.0/knockout-min.js"></script>
</head>
<body>
<ul data-bind="foreach: ['cats', 'dogs', 'fish']">
<li>The value is <span data-bind="text: $data"></span></li>
</ul>
<script>
ko.applyBindings();
</script>
</body>
</html>
However the equivalent with SKO does not work, with console message "Can't find variable: $data":
<head>
<title>semanticko testing</title>
<script type="text/javascript" src="https://raw.github.com/antoniogarrote/semantic-ko/semantic/dist/semko.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
</head>
<body>
<ul data-bind="foreach: ['cats', 'dogs', 'fish']">
<li>The value is <span data-bind="text: $data"></span></li>
</ul>
<script>
sko.applyBindings();
</script>
</body>
</html>
My question is: Have I misunderstood whether this should work, or have I written it wrong? Could you please post an example of how to build a UL or table with SKO using the foreach binding?
Thanks!