Hello im trying to save a model to database. I'm just typing in the value of a title to save it because my id is auto increment. I have tried it but it didn't worked. Can anyone help me?
And what urlRoot or url function i need to specify in my Backbone Model? Do I need to specify url of my collection or?
Model:
var DocumentUser = Backbone.Model.extend({
urlRoot: '/app_dev.php/user'
});
Here is my save function:
save: function(method, model, options) {
this.model = new DocumentUser();
this.model.save({
title: $('#title').val()
}, {
success: function(model, respose, options) {
console.log('The model has been saved to the server');
},
error: function(model, xhr, options) {
console.log('Something went wrong while saving the model');
}
});
}