【问题标题】:Javascript - Array push for AutoCompleteJavascript - 自动完成的数组推送
【发布时间】:2012-11-05 10:04:15
【问题描述】:

我正在开发一个从数组中读取的自动完成搜索栏。我需要解析一个 JSON 文件并将名称推送到一个数组中。除了推送到实际数组的正确命令外,我一切正常。我会用什么来推送到下面的数组?

    $("#schoolLocal").autocompleteArray(
    [],
    {
        delay:10,
        minChars:1,
        matchSubset:1,
        onItemSelect:selectItem,
        onFindValue:findValue,
        autoFill:true,
        maxItemsToShow:10
    }
);

我用过 $("#schoolLocal").autocompleteArray.push(name);

当然这没有用。

感谢任何帮助。 谢谢!

【问题讨论】:

标签: javascript arrays json autocomplete array-push


【解决方案1】:

什么是自动完成数组?数组还是函数?

假设它是一个数组,那么:

// declare the array  with 2 sub arrays,1 for names and other for definitions (?)
$("#schoolLocal").autocompleteArray = new Array(new Array(),{
        delay:10,
        minChars:1,
        matchSubset:1,
        onItemSelect:selectItem,
        onFindValue:findValue,
        autoFill:true,
        maxItemsToShow:10
    }
);

//push to the names array
$("#schoolLocal").autocompleteArray[0].push(name);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-04
    • 2015-09-06
    • 2015-02-16
    • 1970-01-01
    • 2017-09-19
    相关资源
    最近更新 更多