在jQuery自动完成功能中设置下拉菜单的文本

时间:2020-07-21 05:32:43

标签: javascript jquery autocomplete jquery-ui-autocomplete

我将jQuery自动完成功能用于搜索功能。

我导入的源是一个具有多个图层的数组,例如:国家->城市->街道

"01": {
    "name": "country",
    "children": {
      "0101": {
        "name": "USA",
        "children": {
          "010101": {
            "name": "New York",
            "children": {
              "010101": {
                "name": "Mandison Street",
                "children": false
              }
            }
          },
          "010102": {
            "name": "Boston",
            "children": {
              "010102": {
                "code_text": "010102",
                "name": "Fanway Street",
                "children": false
              }
            }
          },
          "010103": {
            "name": "Baltimore",
            "children": {
              "010103": {
                "name": "Orange street",
                "children": false
              }
            }
          },
          "010104": {
            "name": "San Francisco",
            "children": {
              "010104": {
                "name": "Sunset street",
                "children": false
              }
            }
          },
          "010105": {
            "name": "Seattle",
            "children": {
              "010105": {
                "name": "Sailor Street,
                "children": false
              }
            }
          },
          "010106": {
            "name": "Houston",
            "children": {
              "010106": {
                "name": "Moon Road",
                "children": false
              }
            }
          }
        }
      },
    },
}

搜索时,下拉菜单呈现:

国家>美国>纽约>曼迪森街

国家>美国>波士顿> Fanway Street

但是我希望下拉菜单仅显示街道名称:

丹迪街

FanWay Street

在哪里以及如何实现这种外观?

谢谢!

0 个答案:

没有答案