保存模型集合backbone.js中超出最大调用堆栈大小?
如何将模型数组发送到骨干网中的Post API方法?
我在我的mvc应用程序中使用backbone.js,我有一个场景,我必须将一个数组传递给Rest API中的Post方法。 我想发送一个模型数组,然后调用this.collection.create(model)。 我正在尝试将Post方法称为
     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方法的模型数组,我想在Post方法中接收这些模型数组,如下所示
public HttpResponseMessage Post(InsuranceAddressViewModel[] model)
{
return null;
}
但是我在Post方法中获得了null数组。 我的模型转换为json的方法是好的,还是要做别的。 我尝试了几个解决方案,但无法得到想法。 请指导
我正在尝试这个解决方案
当模型中的控件涉及到JSON时。 它正在提供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");
                    }
                }
您是否想要将模型添加到现有的集合中,还是试图用一堆模型替换集合? 如果后者使用:
this.collection.reset(e.models);
  以下this.collection.create(myArrayofModels );  '用于在集合中创建模型的新实例。'  在你上面的例子中,你正在粘贴一个字符串。  Backbone然后尝试将该字符串作为模型添加到您的集合中。 
上一篇: Maximum call stack size exceeded in saving model collection backbone.js?
下一篇: Saving jQuery UI Sortable's order to Backbone.js Collection
