Closed zimt28 closed 8 years ago
I think you've hit upon the big gotcha when not declaring a viewmodel or certain properties explicitly, namely that a property cannot be used reliably as a helper before each of its dependencies have been bound via {{bind}}
.
The reason is that when _isFormValid
is run as a helper the first time, there are no existing properties to register as dependencies for the computation, so it won't rerun reactively at a later time.
As the documentation says, you can either make sure you're only using _isFormValid
after all of the {{bind}}
statements that create the viewmodel fields it depends on, or you can declare the properties explicitly.
I gave it another shot, overcoming this limitation of ViewModel, and I'm happy to say that I've succeeded. I'm pushing a new release later today.
I've released 0.8.0
– please try this version and see if it solves your problem.
Hm, the helper still doesn't work /:
Is it the same if you use the helper after the {{bind}}
statement in the template?
No, that works. But it dosen't fit my UI
That's strange. And you're sure you are on 0.8.0
? And the bind and helper are in the same template? Does it work if you declare the property explicitly in the viewmodel definition?
I found a bug in this feature – it doesn't work the second time the same template is used. There should be an exception in the console, have you noticed it?
The new version 0.8.1
fixes this bug. Please try it, if you haven't abandoned this package yet. Cheers.
There was nothing logged to the console, but I'll just try 0.8.1
and let you know how things look :)
Now 0.8.2
.
EDIT: Now 0.8.3
.
Works now :+1:
Great – thanks a lot for following up on this.
I have a form with a lot of fields, every field is bound to a ViewModel property. It looks like I can just omit defining those properties in my ViewModel, which saves me a lot of
field: ''
lines.However, it also causes a problem:
My
_submitForm
function always logs the correct value, but the_isFormValid
function doesn't work as a template helper anymore when I comment out the properties at the top. Is this behavior intended?