ユーザーモデル
define(
[
'backbone'
],
function (Backbone) {
return Backbone.Model.extend({
url: '/proxy.php/users.json',
defaults: {
'first_name': '',
'last_name': '',
'work_email': ''
},
validation: {
first_name: {
required: true,
msg: 'Please enter a first name'
},
last_name: {
required: true,
msg: 'Please enter a last name'
},
work_email: {
required: true,
msg: 'Please enter a valid email'
}
}
});
}
);
セーブデータを見る
onSave: function (ev) {
ev.preventDefault()
var details = $('.edit-user-form').serializeObject()
var object = new User()
return object.save(details, {
success: function (response) {
console.log(response, 'response')
}
})
},
詳細 =
{first_name: "", last_name: "", birthdate: "", job_title: "", job_start_date: ""…}
birthdate: ""
first_name: ""
job_probation_ends: ""
job_start_date: ""
job_title: ""
last_name: ""
personal_address: ""
personal_email: ""
personal_phone_number: ""
work_address: ""
work_email: ""
work_phone_number: ""
問題、バックボーンによって送信されたリクエストは、フォーム データを次のように送信します。
model:{"first_name":"","last_name":"","work_email":"","birthdate":"","job_title":"","job_start_date":"","job_probation_ends":"","work_address":"","work_phone_number":"","personal_email":"","personal_address":"","personal_phone_number":""}
属性をモデルのサブオブジェクトにするのはなぜですか? ルートとして送信される属性を希望します。