简体   繁体   中英

tokeninput showing all data instead of filterting

I have a jquery-tokeninput for selecting members in an app. The dropdown when typed in shows all data rather than filtering. Funny thing it it puts in bold what it should be filtering by.

JSON:

[{"name": "Bill Bailey", "id": 2}, {"name": "Will Pimblett", "id": 3}, {"name": "Frank Surname", "id": 4}, {"name": "Mary Smith", "id": 5}, {"name": "Will Pimblett", "id": 6}]

HTML:

<div class="token-input-container">
<form action="." method="GET">
<div class="input-append">
    <input type="text" id="token-input" name="names"/>
    <button type="submit" class="btn token-input-submit">Select</button>
    <script type="text/javascript">
    $(document).ready(function () {
        $("#token-input").tokenInput("/members/api/tokeninput-data", {resultsLimit:2,theme:'facebook',hintText:'Type in part of a members name...'});
    });
    </script>
</div>
</form>
</div>

And apologies for the blue screenshot, it was the only whay I could get it

一个相当蓝色的屏幕截图,必须运行萤火虫才能获取图片

When you're using an external URL to generate your JSON array, you must do the search logic yourself, and return only the selection of JSON items you relevant to the query typed. (This is to allow you to search databases and what-have!)

By default, your query (data typed in) is found in $_GET['q'] on your server side script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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