KnockoutJS Script Reference
I am attempting to use KnockoutJS in a sample project for the HTML 5 Viewer. I extended the Quickstart Custom Module and tried numerous different ways to get a basic ko databinding to work with no success. I removed all of my application components and tried to implement the HelloWorld example that KnockOutJS published on their site:
http://knockoutjs.com/examples/helloWorld.html
Pretty simple stuff, but I can't get it to work. I tried adding the below script ref to the ViewModel and it seems to load, but the binding does work in my module.
<script src="Resources\Scripts\Knockout-3.2.0.js" type="text/javascript"></script>
I also tried adding the sample code to the View and it didn't bind either. I went back to the basics and directly added the HelloWorld code to the Index.html page with the same script reference and it worked. I just can't get the code to work in my Custom module. I'm not even sure where to look. Anyone have some suggestions?
-
Scripts tags need to be added programmatically, or referenced in static HTML (e.g. index.html). They do not work in Views. Referencing that script in your HTML will give you access to KO all over your application. I should point out that the viewer has its own data-binding system that may be of use to you. It's quite similar to Knockout in practice. If that's an option, see the SDK Samples that we ship in the HTML5 SDK. There are some examples there.
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
1 kommentar