简体   繁体   English

Dojo FilteringSelect-完整的JSON响应数据不可见

[英]Dojo FilteringSelect - Full JSON Response Data Not Visible

Trying to convert a jQuery autocomplete to a Dojo version. 尝试将jQuery自动完成功能转换为Dojo版本。 Initally followed this advice ( Textbox autocomplete with DOJO ), but switched to JsonRest . 最初遵循此建议( 使用DOJO进行文本框自动完成 ),但切换到JsonRest

When entering input (eg. "th") i can see the proper JSON response in the console, [{"id":"thing1","label":"thing1"},{"id":"thing2","label":"thing2"},{"id":"thing3","label":"thing3"}] , but no list of options appears on screen. 输入输入内容(例如“ th”)时,我可以在控制台中看到正确的JSON响应, [{"id":"thing1","label":"thing1"},{"id":"thing2","label":"thing2"},{"id":"thing3","label":"thing3"}] ,但屏幕上没有选项列表。 When the focus leaves the target input , it's always autocompleted with the first element ("thing1" in this example). 当焦点离开目标input ,它总是自动完成第一个元素(在此示例中为“ thing1”)。

// DOM Element
<div id="things"></div>

// Get data
var jsonStore = new JsonRest  ({  
    target: "/ajax_suggest/autocomplete"
});

// Autocomplete attempt
ready(function(){

    var thingSearch = new FilteringSelect({
        id: "things",
        name: "things",
        store: jsonStore,
        placeHolder: "Search the things...",
        searchAttr: "term",
        onSearch: function(results, query) {
            console.log(JSON.stringify(results));
        }                   
    },"things");

    thingSearch.startup();

});

So, at this point, i'm satisfied that the data is arriving correctly after the input data has been processed, and ultimately, the contents of the input are "autocompleted", but i'm missing something, or haven't grasped something, pretty fundamental here to get the full response to be displayed! 因此,在这一点上,我很满意在处理完input数据之后数据能够正确到达,并且最终, input的内容是“自动完成的”,但是我缺少了一些内容,或者没有掌握任何内容,这里非常基本,可以显示完整的响应!

您有searchAttr: "term" ,但是“ term”不在您的JsonRest存储中-我想您希望将其作为searchAttr: "label"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM