바라건대, 이것은 바보 같은 질문이 아닙니다.속성을 설정하고 요청을 보내는 메소드의 올바른 이름
var Appointment = Backbone.Model.extend({
urlRoot: '/appointments',
defaults: function() {
return {
'Date': new Date(),
'Status': AppointmentStatus.UPCOMING
};
}
});
내가 Status
를 업데이트 순전히 Appointment
에 메서드를 추가 할 :
function(newStatus) {
$.ajax(this.url() + '/status', {
data: { status: newStatus },
type: 'POST',
success: _.bind(function() {
this.set('Status', newStatus);
}, this);
});
}
. setStatus
, updateStatus
또는 다른 항목이 있어야하나요? 이름을 보통 set
과 쉽게 구분할 수 있기를 바랍니다 (이는 setStatus
이 잘못된 것처럼 보입니다).
감사합니다. 너는 처음이었다. 건배. – TheCloudlessSky