Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Bug in can.route.map / can.map.define?

$
0
0
The reason locationIds is always empty is because this particular example makes a new findAll to load locations each page load:

appState.attr('locations', new Locations.List({}))

And each location has no selected property, so the locationIds serialize function returns an empty list.  

If there is originally a list of selectedIds, those get overwritten with this new list after the Locations are loaded.

The set method is called once because if the URL is locationIds=2 on page load, it will run the setter function, but soon after, the locations list loads and this causes locationIds' serialize method to run and return an empty list, so in this case, this is expected behavior.

In a real app, this could be solved by storing location items in localStorage so this state is maintained between page loads.

Viewing all articles
Browse latest Browse all 3491

Trending Articles