1
백본 및 서버에서 ID (api/order/ID/call 및 api/order/ID/status) 다음에 다른 끝점을 사용하여 요청을 보냈습니다. 나는 분명히 다른 행동에 따라 이것들을 설정할 필요가있다.다른 URL 끝점을 가진 백본 세트 저장 (PUT) 요청
CallToBar: function(el){
log("CallToBar Action");
el.preventDefault();
el.stopPropagation();
var target = $(el.currentTarget);
target.text('Calling...');
var that = this;
this.model.save({}, {
url: '/venues/orders/' + this.model.id + '/call',
data: '',
success: function(){
target.text('Called');
timeout = setTimeout(function() {
if(!$(this.el).find('.additional-options').hasClass('hide')){
that.orderClicked();
}
target.text('Call to bar');
}, 1500);
}
});
},
내가 URL에 연결된 다른 엔드 포인트에 대한 능력을 갖고 싶어 : 나는 옵션 URL을 설정 전화 기능이
sync: function(method, model, options){
if (method == 'PUT' || method == 'update') {
model.url = '/venues/orders/' + model.id + '/status';
var jsonData = {};
jsonData.staffid = 1;
jsonData.groupid = 0;
jsonData.statusid = this.get('status.statusid');
//if the options url is set use that otherwise use /status
if(options.url){
model.url = options.url;
}
options.data = JSON.stringify(jsonData);
}
return Backbone.sync(method, model, options);
}
: 나는 모델 동기화를 오버라이드 (override)/확장하여 작동 상태를 가지고 이상적으로 동기화/저장/설정
패치는 정말 필요하지 않습니다. 호출은 방금 attr을 변경하고 싶지 않습니다. 또한 PATCH가 현재 서버에 구성되어 있지 않습니다. – Labithiotis