Your helper - ~editMode()
is not observable - JsViews does not know that it has a dependency on model.editMode
- so observable changes to model.editMode
will not trigger updates on bindings to ~editMode()
.
But you can declare a dependency, and it will then work:
$.views.helpers.editMode.depends = [model, "editMode"];
Here it is http://jsfiddle.net/U3dZ8/5/.
BTW the syntax here is that if you want to declare a dependency on a path on a different object than the current data object, you can pass in to the depends
array any object, followed by one or more paths taking that object as root: ['path.from.currentObject', otherObject, 'path1.from.otherObject', 'path2,from.otherObject' .... ]
.
Another thing you can do (for the case where objects or paths are not statically determined up front) is to supply a function .depends = function() {return [listOfPaths_OrObjectsFollowedByPaths]};
An alternative (for your sample) to using the editMode() function with declared dependency (a JsViews computed observable) is to bind directly to model.editMode
- as in:
data-link="visible{:!~model.editMode}"
or data-link="visible{:~model.editMode}"
.
To do that you just need to pass in the model as a helper object:
jsDropDownsTemplate.link("#myDropDowns", model.myRelations, {model: model});
Here is that one: http://jsfiddle.net/U3dZ8/6/.