New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
observableArray removeall then push items that look similar (clones) with one prop value different won't update list #2394
Comments
Is it maybe because the list size is exactly the same, ie, 20 items before removeAll(), 20 items after push finishes? What's also odd is the results are sorted by distance, and the DOMElements seem to get rearranged according to the sorting, but the internal fields don't get re-bound... showing the old distances, but sorted differently because the underlying objects have different distance calculations. Seems like I need to somehow tell the children trackers within observableArray to refresh/reset or something. I'm stumped. |
https://stage-arbormemorial.cp-access.com/en/locations.aspx?province=Ontario&city=Toronto&postal= You'll see the weird effect when you input a postal code like M8W 4H7 into postal code field (and click Search Locations. Note, when you click SearchLocations it uses HistoryJS to update URL wihtout browsing. If you go to url bar and then hit enter, with that postalcode querystring value filled everything works... ko even changes the order of the branches according to the sort, but none of the rows' values' update according to the object. Granted, only one value changed, so knockout is trying to be efficient. This jsfiddle does it similarly but seems to work |
The first link you provided is password-protected, and the jsfiddle link appears to have a bug. When I click the button, it throws an error: |
I was able to get your jsfiddle to work by changing line 60 to use |
Seems strange because removeall calls valueHasMutated internally but there's something else in there trying to be a little "too" smart, a trackChanges or something perhaps?
My scenario calling a service with a lat/lng position, and getting an array of locations with distance calculated.
I first get the full list of locations, then when user clicks something with new position, I call service that calculates all the locations' distance from that address/position/etc, then I clone the items from the full list, adding distance property as I go.
The text was updated successfully, but these errors were encountered: