Ko is not defined using requirejs
I am trying to use requirejs to load knockoutjs as follows:
<script type="text/javascript">
require(['scripts/knockout-2.2.1.debug'], function() {
var someModel = {
firstname: ko.observable('asd')
};
ko.applyBindings(someModel);
});
</script>
Where require.js is loaded using the Script tag above. When this code is executed, I get ko, not an error. What is the right way to do this?
require(['scripts/knockout-2.2.1.debug'], function(ko) {
I'm not sure, but after seeing an example on requirejs, I assume that they load inside the scope of this callback function. Therefore, if you do not accept this in your function, you cannot use it.
Yes, you're right (at least you see them exmaple). if you include 4 libraries, you need to accept 4 parameters. for example, if you downloaded jquery and knockout, you can write it like this:
require(['scripts/jquery.js', 'scripts/knockout-2.2.1.debug'], function($, ko) {