按下按钮后,我需要更改羊驼形的结构。 从Internet上找到的内容中,我使用以下语法创建羊驼毛表单:
$(document).ready(function() {
$("#reload-button").click(function(){
var formControl = $("#form").alpaca("get");
formControl.schema.properties = {
"some-field": {
"default": 15,
"type": "string",
"title": "Number",
"required": true
}
};
formControl.options.fields = {
"some-field": {
"size": 10,
"helper": "Please enter number.",
"placeholder": "Enter number"
}
};
formControl.refresh();
});
$("#form").alpaca({
"schema": {
"type":"object",
"properties": {
"some-field": {
"default": "text",
"type": "string",
"title": "Text",
"required": true
}
}
},
"options": {
"fields": {
"some-field": {
"size": 20,
"helper": "Please enter your name.",
"placeholder": "Enter your name"
}
}
},
"view" : "bootstrap-create",
});
但是每次刷新都会丢失默认值,然后出现。 我认为这是错误的刷新方式,但我没有找到其他任何东西,有人知道该怎么做吗?