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

Bug in Can.Model when defining id field

$
0
0
I found a gap with the can.Model when a different id field is provided. The destroy action is working correctly but not the update one: (CanJS 2.1.4 for Jquery)

  1.    var CollectionType = can.Model.extend({
  2.         findAll: 'GET /api/collectionType',
  3.         findOne: 'GET /api/collectionType/{id}',
  4.         create: 'POST /api/collectionType',
  5.         update: 'PUT /api/collectionType/{id}',
  6.         destroy: 'DELETE /api/collectionType/{id}',
  7.         id: "Code"
  8.     }, {});

Reviewing the code I think I found where the problem is. In the line 8405 where say:

  1. attrs[identity] = id;

Must be changed for:

  1. attrs.id = attrs[identity] = id;

At least that way it is working for me.

Regards,

Xevi.


Viewing all articles
Browse latest Browse all 3491

Trending Articles