Reputation: 11581
I am upgrading my knockout project to durandal and noticed that some standard knockout bindings are not working as expected.
Knockout does not make any difference between this:
<!-- ko text: someObservable" --><!-- /ko -->
and this:
<!-- ko text: someObservable()" --><!-- /ko -->
Durandal's composition engine does not seem to handle the first case (without parantheses) correctly. I end up with string representation of dependentObservable
function instead of it's value:
function dependentObservable() { if (arguments.length > 0) { if (typeof writeFunction === "function") { // Writing a value writeFunction.apply(evaluatorFunctionTarget, arguments); } else { throw new Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters."); } return this; // Permits chained assignments } else { // Reading the value if (!_hasBeenEvaluated) evaluateImmediate(); ko.dependencyDetection.registerDependency(dependentObservable); return _latestValue; } }
Does durandal require parantheses at the end of binding string or is it configurable somehow?
Upvotes: 1
Views: 82
Reputation: 11581
The problem was that I included knockout library twice: it was loaded both synchronously and via requirejs. It turns out requirejs will still load script, even if it is already loaded synchronously.
Adding this to main.js
solves the problem:
define('knockout', [], function() {
return ko;
});
Upvotes: 1