I have having an issues trying to get knockout to play nicely with requirejs (and judging by the number of posts on here, so is everyone else!). Nothing I have read on here have come across this issue.
Below is my config for require:
requirejs.config({
"baseUrl": "/js",
"paths": {
"Model": "App/Model",
"Development": "App/Development",
"Property": "App/Property",
"codemirror": "vendor/codemirror/codemirror-2.37/lib/codemirror",
"galleria": "vendor/galleria/galleria-1.2.9",
"jquery": "vendor/jquery/jquery-2.0.0",
"jquery-ui": "vendor/jquery-ui/jquery-ui-1.10.2",
"jshint": "vendor/jshint/jshint-1.1.0",
"knockout": "vendor/knockout/knockout-2.2.1",
"signalr": "vendor/signalR/jquery.signalR-1.0.1"
},
"shim": {
"galleria": {
deps: ["jquery"]
},
"jquery-ui": {
deps: ["jquery"]
},
"signalr": ["jquery"],
"/signalr/hubs": {
deps: ["jquery", "signalr"]
},
"Development/ViewModel/CreateDevelopment": {
deps: ["signalr", "knockout"]
},
"knockout": {
deps: ["jquery"],
exports: "knockout"
}
}
});
So this should get all of my dependencies, and indeed it does. Here is the require bit:
require(["Development/ViewModel/CreateDevelopment"], function (CreateDevelopment) {
$.connection.hub.start().done(function() {
if (CreateDevelopment !== undefined && CreateDevelopment !== null) {
var createDevelopment = new CreateDevelopment();
createDevelopment.init();
}
});
})
I will probably need to bring in the singalr jquery bit but thats not where I am having an issue.
When I define my module I keep getting the following error:
Uncaught Error: Pass a function that returns the value of the ko.computed (Line 44)
Here is my module
define(["Model/developmentType", "knockout", "signalr", "/signalr/hubs"], function (developmentType, ko)
Now if I use console.log(ko) I can see everything in the library so I cannot understand why I keep getting this error.
The order in which require is getting the libraries is as follows:
- RequireJS
- Main AppJs
- Jquery
- Jquery SignalR
- Knockout
- ViewModel
- Model
Hubs
Uncaught Error: Pass a function that returns the value of the ko.computed
Call Stack:
Any help with this will be greatly received!