0
我是AlpacaJS的新手,想要弄清楚如何做一個簡單的事情,例如用「Select」的值來改變文本字段的內容。AlpacaJS:選擇後以編程方式更改TextField的值選擇
代碼看起來像
$("#form1").alpaca({
"data": {
"name": "Default"
},
"schema": {
"title": "What do you think of Alpaca?",
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Name"
},
"flavour":{
"type": "select",
"title": "Flavour",
"enum": ["vanilla", "chocolate", "coffee", "strawberry", "mint"]
}
}
},
"options": {
"helper": "Tell us what you think about Alpaca!",
"flavour": {
"type": "select",
"helper": "Select your flavour.",
"optionLabels": ["Vanilla", "Chocolate", "Coffee", "Strawberry", "Mint"]
}
}
},
"postRender": function(control) {
var flavour = control.childrenByPropertyId["flavour"];
var name = control.childrenByPropertyId["name"];
name.subscribe(flavour, function(val) {
alert("Val = " + val);
this.schema.data = val;
this.refresh();
});
}
});
我可以看到,在postRenderer函數被調用(因爲我可以看到相關值警報),但是(也許我腦死在這個階段)我不能使用該值刷新文本字段。
乾杯