Closed alnico2001 closed 2 months ago
Thanks for bringing this up, Brent. I'll look into it...
Hi Brent, can you test whether this candidate fix works for you?
Thanks Boris...
The fix does not work in my app; it still only works on whichever path is first. I see see of course that it works in the test file ;-)
This is my actual code using view models:
$.observe(appVm,
"locations()^[].Address()",
"locations()^[].City()",
"locations()^[].State()",
"locations()^[].Zipcode()",
mobileAddressChange)
Ah - interesting. Would you be able to provide me a small test example, with that pattern (or similar) observing view models? "locations()^[].Address()"
(It will save me a bit of time :-) )
Actually, I may be able to use this sample as a starting point: https://www.jsviews.com/#jsvviewmodelsapi@ismanagersample. I'll look into it. (Unless it is easy/rapid for you to come up with a test sample...)
Here is an example I threw quickly together...it looks like the view model is causing the problem...
In this example file: only the first "phones()^[]...."
works...even on initial rendering; never mind Add Phone...
$.observe(person,
"phones()^[].number()",
"phones()^[].ext()"
, changeHandler);
Excellent. Thanks!,
Hi Brent, here is a candidate, for you to test in your environment.
This fix works...Thank you Boris!
Good.
These were in fact two different issues:
"phones^[].number", "phones^[].ext"
and
"phones()^[]
...
Thanks for calling them out!
Resolved, and included in commit v1.0.14
When a new item/object is added to an array, and paths to specific properties are being observed...there are observe inconsistencies...
Observe works for
number
andext
but does not work for newly added phones object asphones
needs to be observed too...$.observe(person,"phones.[].number", "phones.[].ext", changeHandler);
Therefore, this works for newly added phones object, but for
number
only....any additional paths using pattern:phones^[]...
do not work (ext
).$.observe(person,"phones^[].number", "phones^[].ext", changeHandler);
Here is one of your modified samples showing the issue: https://jsfiddle.net/alnico/8cgzwfnx/
To test: on load notice both
number
andext
are observed. Click "Add phone" and changenumber
, it is observed...now changeext
...it is NOT observed.Note: if the 'Add phone' button doesn't work, then copy code into your local env...no idea why it's not working in jsfiddle.