I stumbled upon this post with a possible solution but it's not working and I am getting the same error ko is not define.
I placed this in a it's own JS file as I am assuming knockout.inject needs to be in a module as explained in the original post.
define('knockout.inject', ['knockout'], function (k) {
window.ko = k;
return k;
});
Then this:
require.config({
paths: {
knockout: 'Path to knockout',
// This is the file
knockoutbindings: 'knockout.bindings.orderable'
},
shim: {
"knockoutbindings": {
deps: ["knockout"]
},
map: {
// inject ko back in the global namespace
'*': {
'knockout': 'knockout.inject'
},
// prevent cycles
'knockout.inject': { 'knockout': 'knockout' }
}
}
});
However, I am not sure how to instantiate the file and I get the error: ko is undefined. Followed by the name of the file and directory.
With knockout mapping, all I had to do was:
ko.mapping = komapping;
How do I instantiate this file?