遍历嵌套的JSON对象 - YUI自动完成

时间:2015-08-06 20:35:19

标签: javascript jquery json yui

假设我有两个不同的无关JSON对象从单独的AJAX请求返回

content: [{...}]
    0: {...}
        userId: "22"
        name: "Kevin Johnson"
        Manager: {…}
            managerId: "123"
            name: "Ryan Burke" //will be set as "searchValue"

content: [{...}]
    0: {...}
        companyId: "345"
        companyName: "Trucks-R-Us" //will be set as "searchValue"
        Building: {…}
            buildingId: "5"
            section: "North-West" 

我标记的属性将存储在名为searchValue的变量中(注意它们不在同一级别)

我可以使用YUI's AutoComplete插件访问searchValue,找到我使用resultListLocatorresultTextLocator的组合指定的属性,无论key var autoComplete = new Y.AutoComplete({ inputNode: '#search-string', resultListLocator: 'content', resultTextLocator: function( return /** Find searchValue within nested Object**/), resultHighlighter: 'phraseMatch', maxResults: 10 }); 是什么1}}属性是命名的还是嵌套属性是什么?

searchValue

简短版:在找到与$(event.target).parent().next() 的匹配项之前,我的对象是否可以遍历?

如果这还不够详细,可以详细说明

0 个答案:

没有答案