-2
你好我试图将模型保存到数据库。我只是输入一个标题的值来保存它,因为我的ID是自动递增的。我试过了,但没有奏效。谁能帮我?如何将模型保存到数据库?
我需要在我的骨干模型中指定哪个urlRoot或url函数?我需要指定我的收藏的网址吗?
型号:
var DocumentUser = Backbone.Model.extend({
urlRoot: '/app_dev.php/user'
});
这是我保存功能:
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');
}
});
}
感谢,但我需要的网址放在模型?我收集的网址与所有模型的json响应或? – neko