Closed AlexxVS closed 3 years ago
Thank you very much for posting this. It's a good catch. I'll need to do some investigation... I'll let you know...
Here is a potential update that should address your issues. Can you test that it works correctly for you?
Incidentally, your example is data-linking to util1(), as if it was a computed observable, but for the binding to work, it needs an associated setter function. See https://www.jsviews.com/#computed@getset.
For example, you could write:
let tmpl = $.templates("{^{tag1 Prop1() param1=~hlp.util1(1) /}}");
let utils = {hlp: {
util1: function(a) {
return this._util1;
},
_util1: "initUtil1"
}};
utils.hlp.util1.set = function(val) {
this._util1 = val;
};
tmpl.link("#text1", m, utils);
If you provide a setter, as above, the "view.ctxPrm(...) is not a function" exception will not be thrown.
But with the jsviews.js update provided there will no longer be any exception, even if you don't provide a setter. (Though of course two-way binding will not work unless there is a setter defined...)
Let me know if this works for you...
Thank you, Boris. The update resolves both throwing the exception and double onBind event.
Thanks for confirming. I except to include this in the upcoming version 1.0.10.
The fix concerns two issues:
<input data-link="name()"/>
with name.set
undefined leads to an exception "name is not a function"
. {^{mytag name()/}}
can trigger onBind callback twice.Fixed in release v1.0.10
Hi, Please take a look at this abstract case:
With JsViews versions 1.0.5 and earlier this worked, but starting from 1.0.6 and up to 1.0.9 the "view.ctxPrm(...) is not a function" exception is thrown. Now let's remove "Param1" from bindTo and linkedCtxParam:
Now the exception is not thrown, but onBind callback method is called twice. With versions prior 1.0.6 onBind is called only once.