Jquery 主干形式的对象数组
我正在为我当前的项目使用主干表单,我发现为数组创建模式有困难Jquery 主干形式的对象数组,jquery,jquery-ui,backbone.js,backbone-views,backbone-forms,Jquery,Jquery Ui,Backbone.js,Backbone Views,Backbone Forms,我正在为我当前的项目使用主干表单,我发现为数组创建模式有困难 schema:{ name:{}, description:{}, partition:{}, 'addresses':[{type:'Object',subSchema:{address:{}, description:{}}}] } 这是我的模式 var obj = { name:'suchita',
schema:{
name:{},
description:{},
partition:{},
'addresses':[{type:'Object',subSchema:{address:{}, description:{}}}]
}
这是我的模式
var obj = {
name:'suchita',
description:'device3 desc',
partition:'346',
'addresses':
[{address:'abc', description:'xyz'}]
};
var user=new Model(obj);
这就是我填充模式的地方。现在,我的api希望我发送一个“地址”对象数组,即
地址:
0:{地址:'abc',说明:'xyz'}
1:{地址:'uio',描述:'uiyui'}
但不知怎的,事情并不是这样发生的。您能帮我找出哪里出了问题吗?尝试设置架构字段的类型,例如:
schema:{
name: {type:'Text'},
description: {type:'TextArea'},
partition: {type:'Text'},
addresses:[{type:'Object', subSchema:{
address:{type:'Text'},
description:{type:'TextArea'}
}}]
}
schema:{
name:{},
description:{},
partition:{},
addresses: {type:'List',itemType: 'Object',
subSchema:{
address:{},
description:{}
}
}
}
尝试设置架构字段的类型,例如:
schema:{
name: {type:'Text'},
description: {type:'TextArea'},
partition: {type:'Text'},
addresses:[{type:'Object', subSchema:{
address:{type:'Text'},
description:{type:'TextArea'}
}}]
}
schema:{
name:{},
description:{},
partition:{},
addresses: {type:'List',itemType: 'Object',
subSchema:{
address:{},
description:{}
}
}
}
我知道已经晚了,但我认为带有列表的语法类似于:
schema:{
name: {type:'Text'},
description: {type:'TextArea'},
partition: {type:'Text'},
addresses:[{type:'Object', subSchema:{
address:{type:'Text'},
description:{type:'TextArea'}
}}]
}
schema:{
name:{},
description:{},
partition:{},
addresses: {type:'List',itemType: 'Object',
subSchema:{
address:{},
description:{}
}
}
}
当然,您必须包括主干表单的列表编辑器:
<script src="backbone-forms/distribution/editors/list.min.js"></script>
我还没有检查这是否有效,但我的代码中有一个类似的情况,因此它应该可以工作我知道时间晚了,但我认为带有列表的语法类似于:
schema:{
name: {type:'Text'},
description: {type:'TextArea'},
partition: {type:'Text'},
addresses:[{type:'Object', subSchema:{
address:{type:'Text'},
description:{type:'TextArea'}
}}]
}
schema:{
name:{},
description:{},
partition:{},
addresses: {type:'List',itemType: 'Object',
subSchema:{
address:{},
description:{}
}
}
}
当然,您必须包括主干表单的列表编辑器:
<script src="backbone-forms/distribution/editors/list.min.js"></script>
我还没有检查这是否有效,但我的代码中有一个类似的情况,所以它应该可以工作