Joren
Joren

Reputation: 9935

Backbone.js destroy not passing model information to server?

My model definition:

var Note = Backbone.Model.extend({
    url: '/backbone/notes',

    defaults: function() {
      return {
        id: '',
        text: '',
        date: ''
      };
    },

    initialize: function() {
    },

});

I'm calling destroy on a model thusly:

    delete_note: function(e) {
        this.model.destroy({success: function(model) {
            console.log('success');
        }});            
    },

But if I look at the request in firebug it contains no information about the model so I don't know what to delete on the server side. My gets and puts work fine.

This is the model contents:

Object {text: "fdsasdfasdf", date: "Jun 14, 2013", id: 4685293923860480}

Any ideas?

Upvotes: 1

Views: 385

Answers (1)

Todd H. Gardner
Todd H. Gardner

Reputation: 640

The id of your model will be appended to the url when making requests to the server. So the Gets and Puts that are working should be going to:

/backbone/notes/4685293923860480

Delete should be going to the same URL, but should not include no information beyond that. You should have enough information on what to delete by the URL that was hit and the method that was used.

Upvotes: 1

Related Questions