【问题标题】:bootstrap get ids from tagsinputbootstrap 从 tagsinput 获取 id
【发布时间】:2015-12-17 23:34:28
【问题描述】:

我有库标签输入,我想返回标签的 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() 但没有返回如何处理这个问题?

【问题讨论】:

    标签: twitter-bootstrap bootstrap-tags-input


    【解决方案1】:

    我认为你应该在 typeaheadjs 配置中添加:

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

    然后你会得到值

    elt.tagsinput('items')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-04
      • 2019-01-21
      相关资源
      最近更新 更多