Knockout Switch-case Plugin Is Not Hiding/showing The Correct Value
Solution 1:
You're referencing the github page of the script, not the script file itself.
Correct path: https://raw.githubusercontent.com/mbest/knockout-switch-case/master/knockout-switch-case.min.js
.
P.S.: For JSFiddle, <script>
tag type attribute should be equal to text/javascript
.
Demo: JSFiddle
Solution 2:
Your problem is that the ko-switch plugin is not loaded in your fiddle.
manji solution may not work in some browser (e.g. IE11) because of mime type enforcement: github doesn't return the raw js file with a javascript mime type, which IE refuses to execute with error SEC7112.
Here's a fiddle that works. I've referenced the plugin at rawgithub.com instead (notice there's no dot like in raw.github.com):
<scriptsrc="http://rawgithub.com/mbest/knockout-switch-case/master/knockout-switchcase.min.js"></script><spandata-bind='text:type'></span><div><!-- ko switch: type --><!-- ko case: 'boolean' -->
Im a boolean!
<!-- /ko --><!-- ko case: $else --><span> Im an other!</span><!-- /ko --><!-- /ko --></div>
Tip: to find the error I only had to look at my browser console.
EDIT: sorry I pasted the wrong code, but the fiddle was right ;)
Post a Comment for "Knockout Switch-case Plugin Is Not Hiding/showing The Correct Value"