-2
안녕하세요, 저는 모델을 데이터베이스에 저장하려고합니다. 내 ID가 자동 증가이기 때문에 제목을 저장하기 만하면됩니다. 나는 그것을 시도했지만 효과가 없었습니다. 누구든지 나를 도울 수 있습니까?모델을 데이터베이스에 저장하는 방법은 무엇입니까?
그리고 내 백본 모델에서 지정해야하는 urlRoot 또는 url 기능은 무엇입니까? 내 컬렉션의 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 응답 또는 내 컬렉션의 URL? – neko