【发布时间】:2017-10-17 08:40:18
【问题描述】:
我希望有人能给我一个提示。 Ic 创建了一个具有不同数组字段的表单。其中一个有两个下拉列表,第二个中的条目取决于第一个的选择。这应该很容易用观察者解决,只需在第一个中的选择发生变化后加载第二个中的值。目前没问题。
但是现在的问题是,如果我对静态字段集进行测试,这很容易,但我无法弄清楚我必须如何处理动态添加字段的观察者。
另外,我不确定是否可以选择解决相对字段而不是绝对字段。会容易得多,因为我必须始终在实际对象中设置值。
这是一个小小提琴设置https://jsfiddle.net/ygwuxrbk/
{
"schema": {
"title": "Erfassung",
"type": "array",
"items": {
"title": "Account",
"type": "object",
"properties": {
"services": {
"type": "array",
"title": "Services",
"required": true,
"uniqueItems": true,
"items": {
"description": "Angebotenen Services des Anbieters",
"type": "object",
"id": "arr_item",
"properties": {
"category": {
"type": "select",
"title": "Service Kategorie",
"required": true,
"$ref": "#/definitions/categories"
},
"service": {
"title": "Service",
"type": "select",
"enum": service["Beauty & Wellness"]
}
}
}
}
}
},
"definitions": {
"categories": {
"enum":
categories
},
}
},
"options": {
"fields": {
"category": {
"type": "select",
"label": "Category",
"onFieldChange": function (e) {
console.log(this.getValue());
}
}
}
},
"form": {
"attributes": {
"action": "http://testcompany.com/echo.php",
"method": "post"
},
"buttons": {
"save": {
"title": "Save",
"click": function(e) {
alert(JSON.stringify(this.getValue()));
//this.submit(); // submit it via regular HTTP post
this.ajaxSubmit(); // submit via ajax
}
}
}
}
}
【问题讨论】:
-
好的,我找到了我的问题。我只是使用了错误的路径结构。
标签: javascript jquery arrays observers alpacajs