使用 JSON 填充组合框.Dojo 1.7打破了它.:-(.



我有一个应用程序,它正在用JSON源填充组合框。网页内容如下...

<label for="user">User: </label>
<input dojoType="dijit.form.ComboBox" class="selectionNav tableData" value="" name="user" id="sample/user">

来自示例/用户的 JSON"在这里......

{
"identifier": "user",
"label": "label",
"items": [
    {
        "user": null,
        "label": null
    },
    {
        "user": "Joe Wilkie",
        "label": "Joe Wilkie"
    }
  ]
}

在道场 1.7 之前,这就像一个冠军!升级道场后,我在 firebug 中注意到 JSON 仍在正常获取并且有效,但它不再填充组合框。

任何人知道如何解决这个问题吗?提前非常感谢。珍妮

ComboBox 上的默认搜索属性是 name,该属性不在存储中。 将searchAttr添加到组合框。

<input dojoType="dijit.form.ComboBox" searchAttr="label" ...

这是我完整的测试代码:

<!DOCTYPE html>
<html >
<head>
    <link rel="stylesheet" type="text/css" href="dojo/1.7.2/dijit/themes/claro/claro.css" />
    <style type="text/css">html, body {
        width: 100%;
        height: 100%;
        margin: 0;
    }</style>
    <script src="dojo/1.7.2/dojo/dojo.js" data-dojo-config="parseOnLoad: true"></script>
    <script>require(["dojo/ready", "dojo/data/ItemFileReadStore", "dijit/form/ComboBox"], 
    function(ready, Store, ComboBox) {
      ready(function() {
        var store = new Store({data: {
          "identifier": "user",
          "label": "label",
          "items": [
              {
                  "user": null,
                  "label": null
              },
              {
                  "user": "Joe Wilkie",
                  "label": "Joe Wilkie"
              }
            ]
        }});
    dijit.byId('user').set('store', store);
  });
});
</script>
</head>
<body class="claro">
    <label for="user">User: </label>
    <input dojoType="dijit.form.ComboBox" searchAttr="label" class="selectionNav tableData" value="" name="user" id="user" />        
</body>
</html>

最新更新