I'm having some trouble saving changes to individual models in a collection. Models that have been loaded (via a collection .reset()) are issuing a POST (as if they were new) instead of the expected PUT.

Here's the approach I'm taking:

AppView

  • Loads the child collection via this.model.childcollection.reset(JSON DATA FROM SERVER);

  • In it's render function, creates a new childview for each item in the collection and renders it:

    render: function() {
            var el = this.el;
            this.model.childcollection.forEach(function(s) {
            var view = new ChildView({ model: s });
            el.append(view.render().el);
        });
        return this;
    },
    

ChildView

  • In one of its events it is changing some values of the underlying model and calling save:

    this.model.set(
            {
                ValueA: somevalue,
                ValueB: somevalue
            },
            {
                error: function() {
                    console.log("Error saving model");
                },
                success: function() {
                    console.log("Model change saved");
                }
            });
        this.model.save();
    

Observations:

  • POST (with no child id) is called instead of PUT (with child Id)
  • Child elements have Ids set

Can anyone tell me why this may be happening?

Edit
Report