보내는 방법 모델의 배열을 백본에서 Post API 방법으로 보내시겠습니까?모델 콜렉션 backbone.js를 저장하는 데 최대 호출 스택 크기가 초과 되었습니까?
내 mvc 응용 프로그램에서 backbone.js를 사용하고 있으며 Rest API의 Post 메서드에 배열을 전달해야하는 시나리오가 있습니다. 배열 배열을 보내고 this.collection.create (model)를 호출하려고합니다. 나는
var ModelArray = Backbone.Model.extend({
urlRoot: av.api.patientInsuranceAddress,
toJSON: function() {
return this.collection.toJSON();
}
});
var modelCollection = new ModelArray(
{
collection: this.collection.models
});
modelCollection.save();
여기 e.models 내가 JSON과 Post 메소드를 호출로 변환 모델의 배열이 그대로 포스트 메소드를 호출하려고 거라고, 그리고 난이
같은 포스트 방법에 모델의 배열을받을하려면public HttpResponseMessage Post(InsuranceAddressViewModel[] model)
{
return null;
}
그러나 Post 메서드에서 null 배열이 나타납니다. json으로 모델의 배열을 변환하는 나의 방법은 괜찮습니까, 아니면 다른 것을해야 할 것입니다. 솔루션 몇 가지를 시도했지만 아이디어를 얻을 수 없었습니다. 컨트롤이 모델에서 toJSON에 올 때 나는이 solution
을 시도하고
안내하시기 바랍니다. Uncaught RangeError : 최대 호출 스택 크기를 초과했습니다. 기존 컬렉션에 모델을 추가하려고하거나 모델의 무리와 함께 컬렉션을 대체하기 위해 노력하고있다
I am posting my code here
var PayerAddress = Backbone.Model.extend({
urlRoot: av.api.patientInsuranceAddress,
defaults: {
Address: '',
City: '',
State: '',
Zip: ''
},
toJSON: function() {
return this.collection.toJSON();
}
});
var Payers = Backbone.Collection.extend({
//url: av.api.patientInsuranceAddress,
model: PayerAddress,
});
"Done": {
class: 'btn',
text: "Done",
click: function() {
payerName = self.$el.find('#Payer').val();
var ModelArray = Backbone.Model.extend({
urlRoot: av.api.patientInsuranceAddress,
toJSON: function() {
return this.collection.toJSON();
}
});
var modelCollection = new ModelArray(
{
collection: self.collection.models
});
modelCollection.save();
//self.closedialog();
$(this).dialog("close");
}
}
'myArrayofModels'는 배열이 아니며, 단일 문자열입니다. –