Closed stadskle closed 11 months ago
Nice plugin! I am trying to use this against a third party company lookup, but I am not able to get serverDataKey to get the data from the nested structure. Is that not supported or have I misunderstod?
Autocomplete.init("#input-id", { fullWidth:true, valueField: "id", labelField: "name", highlightTyped: true, onSelectItem: console.log, liveServer: true, suggestionsThreshold:3, queryParam:'q', server: 'https://no.search.two.inc/search', serverParams: {'limit':10, 'offset': 0}, noCache: false, serverDataKey: 'items' });
The server response looks like this:
{ "status": "success", "data": { "total": 3, "items": [ { "id": "981617517", "name": "EQUINOR BIL OSLO", "highlight": "\\u003cmark\\u003e\\u003cb\\u003eEQUINOR\\u003c/b\\u003e\\u003c/mark\\u003e \\u003cmark\\u003e\\u003cb\\u003eB\\u003c/b\\u003eIL\\u003c/mark\\u003e OSLO", "code": "FLI", "score": 46.73977867834532 }, { "id": "993015253", "name": "EQUINOR BIL BERGEN", "highlight": "\\u003cmark\\u003e\\u003cb\\u003eEQUINOR\\u003c/b\\u003e\\u003c/mark\\u003e \\u003cmark\\u003e\\u003cb\\u003eB\\u003c/b\\u003eIL\\u003c/mark\\u003e \\u003cmark\\u003e\\u003cb\\u003eB\\u003c/b\\u003eERGEN\\u003c/mark\\u003e", "code": "FLI", "score": 46.581858857682334 }, { "id": "999145671", "name": "EQUINOR BERGEN BÅTLAG", "highlight": "\\u003cmark\\u003e\\u003cb\\u003eEQUINOR\\u003c/b\\u003e\\u003c/mark\\u003e \\u003cmark\\u003e\\u003cb\\u003eB\\u003c/b\\u003eERGEN\\u003c/mark\\u003e \\u003cmark\\u003e\\u003cb\\u003eB\\u003c/b\\u003eÅTLAG\\u003c/mark\\u003e", "code": "FLI", "score": 44.4037772735859 } ] } }
I have tried serverDataKey: 'items' andserverDataKey: 'data.items'. But I just getCannot read properties of undefined (reading 'items')`. etc.
serverDataKey: 'items' and
. But I just get
sorry for the late response i seem to have missed it
yes indeed i need to add nested support, good catch
Fixed in https://github.com/lekoala/bootstrap5-autocomplete/releases/tag/1.1.24
Nice plugin! I am trying to use this against a third party company lookup, but I am not able to get serverDataKey to get the data from the nested structure. Is that not supported or have I misunderstod?
The server response looks like this:
I have tried
serverDataKey: 'items' and
serverDataKey: 'data.items'. But I just get
Cannot read properties of undefined (reading 'items')`. etc.