Having an issue with durandal's compose binding as it is looking for views under app/viewmodels
instead of app/views
The ViewModel code:
define(["fields/fieldClosures"], function (fields) {
var ctor = function(opt) {
this.value = opt.value;
};
return fields.readonly.default = ctor;
});
The View using compose binding:
<div data-name="fields">
<div data-bind="css: { 'has-error': hasError }" class="form-group">
<label data-name="label" data-bind="attr: { 'for': id }" class="col-lg-3 control-label"></label>
<div data-name="field" class="col-lg-9"></div>
</div>
</div>
The issue arises when data-name="field"
gets translated to data-bind="compose: field"
and the viewLocator is not able to load the view correctly.
Update: The path to VM is \App\viewmodels\form\fields\readonly\text.js
The VM that holds the field member:
define(["fields/fieldClosures",
"fields/readonly/text",
"fields/readonly/date",
"fields/readonly/number"], function (fields) {
// Code for factory and constructor injection
// ...
return ctor;
});
The references are created using a factory, but the constructors are injected with requirejs as usual.
Another Update:
'fields' is added at the beginning:
requirejs.config({
paths: {
'text': '../Scripts/text',
'durandal': '../Scripts/durandal',
'plugins': '../Scripts/durandal/plugins',
'transitions': '../Scripts/durandal/transitions',
"fields": "viewmodels/form/fields"
}
});