These are chat archives for canjs/canjs

Apr 2017
Szabolcs Schmidt
Apr 07 2017 11:17


I've run into something I cannot decide whether it is a bug or not?!
I'm using CanJS 3.
If I give a custom id property to my can.Model and issue a findOne() command for the second time - to reload the model - can-connect/can/model/model.js does not find the id value in the response data and so it does not refresh the model in the store. model.js@1.3.8 in line 41:

var idProp = || 'id';

results 'id' as idProp value but should result the custom id property name. If I rewrite this line to this:

var idProp = || this.idProp || 'id';

i.e. add 'this.idProp' to the line then idProp gets the correct value, my custom id property name and the model in the store refreshes.

I would like to ask if my solution were right? Could you give me a better one?

Here is a fiddle which works, it uses 'stock' id property, the model is refreshed after the second findOne call:

And here is a fiddle with custom id prop value which does not refresh the model after the second findOne call:

In the example after clicking the Save link the changeCount in the model should increase because it is increased on the 'server' side.


Nico R.
Apr 07 2017 19:58
I’m moving from donejs 0.9 to 1.0 and import route from "can/route/“; won’t work now. What is the new way of imporing route?
Matthew Phillips
Apr 07 2017 20:00
Nico R.
Apr 07 2017 20:37
route is still causing me some trouble
I guess a lot changed
but I get a lot of TypeError: Cannot define property:page, object is not extensible. (page is the first ‘segment’ of my route)
Nico R.
Apr 07 2017 20:42
I have something like this:
route('{page}', { section: null, subSection: null });
route('{page}/{section}', { page: null, section: null, subSection: null });
route('{page}/{section}/{subSection}', { page: null, section: null, subSection: null });
it used to work
using :section notation
Nico R.
Apr 07 2017 20:50
this seems to work
but this one not:
route('{page}/{section}', {section: null});
I’m not even reading from any of those, just trying to render http://localhost:8080/one/two
and that triggers TypeError: Cannot define property:section, object is not extensible.
Nico R.
Apr 07 2017 20:55
I copied from place-my-order this:
route('{page}', { page: 'home' });
route('{page}/{slug}', { slug: null });
route('{page}/{slug}/{action}', { slug: null, action: null });
and didn’t work either
TypeError: Cannot define property:slug, object is not extensible.
Chasen Le Hara
Apr 07 2017 21:12
@sszabolcs That seems like a reasonable change, would you mind filing an issue here please?
Nico R.
Apr 07 2017 21:12
fixed: I had to explicitly declare the variables in the defineMap