羊驼标题更改不会生效 post 刷新

Alpaca title change won't take effect post refresh

我一直在尝试稍微修改文档中的可观察对象示例。我希望下面的字段更改标题,而不是根据用户在单选按钮中的选择使用不同的枚举。

这是一个 运行 fiddle

到目前为止的代码片段如下:

var teams = {
  "None": "None",
  "Milwaukee": "Milwaukee",
  "Cleveland": "Cleveland",
  "Boston": "Boston"
};

$("#form1").alpaca({
  "schema": {
    "type": "object",
    "properties": {
      "city": {
        "title": "Pick a City",
        "type": "string",
        "enum": ["Milwaukee", "Cleveland", "Boston"]
      },
      "team": {
        "title": "nothing yet",
        "type": "string",
      }
    }
  },
  "postRender": function(control) {
    var city = control.childrenByPropertyId["city"];
    var team = control.childrenByPropertyId["team"];
    team.subscribe(city, function(val) {
      //city.schema.title = teams[project.data];
      console.log('updating field title');
      this.schema.title = teams[val];
      //this.parent.refresh();
      this.refresh();
      console.log('refreshed')
    });
  }
});
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.5/handlebars.min.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>

<script src="https://code.cloudcms.com/alpaca/1.5.17/bootstrap/alpaca.min.js"></script>
<link href="https://code.cloudcms.com/alpaca/1.5.17/bootstrap/alpaca.min.css" rel="stylesheet"/>

<div id="form1"></div>

要更改字段的标签,您应该使用选项而不是架构。

this.options.label = teams[val];

告诉我这是否不适合你。