错误 - 缺少字符串 - jQuery Typeahead

ERROR - Missing string - jQuery Typeahead

我正在使用 jQuery Typeahead plugin,但如果我尝试设置初始数据,则会发生错误并且输入值为 false

这是我的配置:

var typeaheadOptions = {
        dynamic: true,
        display: ['title'],
        template: '<span>{{title}}</span>',
        cache: true,
        debug: true,
        multiselect: {
            matchOn: ['id'],
            data: [{title: 'title1'}, {title: 'title2'}],
            callback: {
                onCancel: function(node, item) {removeItem(item)}
            }
        },
        source: {
            posts: {
                ajax: {
                    method: 'GET',
                    url: remoteURL,
                    data: {search: '{{query}}'}
                }
            }
        },
        callback: {
            onClick: function(node, a, item) {addItem(item)}
        }
    };

这里是错误:

ERROR - Missing string": {
  arguments: "",
  function: "helper.namespace()",
  message: "ERROR - Missing string",
  node: "#media-kit-post"
}

这是它的样子:

我是不是漏掉了什么?

我找到了解决方案并想与大家分享:

初始 data 数组中的项目需要一个额外的键值对:matchedKey: 'title'.

所以这是我的工作 options 对象:

var typeaheadOptions = {
        dynamic: true,
        display: ['title'],
        template: '<span>{{title}}</span>',
        cache: true,
        debug: true,
        multiselect: {
            matchOn: ['id'],
            data: [{title: 'title1', matchedKey: 'title'}, {title: 'title2', matchedKey: 'title'}],
            callback: {
                onCancel: function(node, item) {removeItem(item)}
            }
        },
        source: {
            posts: {
                ajax: {
                    method: 'GET',
                    url: remoteURL,
                    data: {search: '{{query}}'}
                }
            }
        },
        callback: {
            onClick: function(node, a, item) {addItem(item)}
        }
    };

额外的键值对确实在 typeahead documentationmultiselect 示例中,但在周围的文本中没有描述。