1

我有库标签输入,我想返回标签的 ID(由用户添加)。在 window.acNodes.ttAdapter 中是具有 id 和 value 但在输入中只有 value 的数组。我怎样才能获得 id?

elt.tagsinput({
        itemValue: 'value',
        itemText: 'value',
        typeaheadjs: {
            name: 'value',
            displayKey: 'value',
            templates: {
            empty: [
              '<p>Could not find this word.</p>'
            ].join('\n'),
            suggestion: Handlebars.compile("<p><strong>{{value}}</strong> <div style='font-size:12px;'>#{{id}} {{author_name}}</div></p>")
        },
        source: window.acNodes.ttAdapter()
  }     
});

tagsinput 有方法 items() 但没有返回如何处理这个问题?

4

1 回答 1

0

我认为您应该添加 typeaheadjs 配置:

...
valueKey: 'id',
...

然后你会得到价值

elt.tagsinput('items')
于 2015-12-17T15:34:28.973 回答