【问题标题】:Bootstrap Tags Input with Typeahead Predefined item from the listBootstrap Tags Input with Typeahead Predefined item from the list
【发布时间】:2015-11-27 05:44:55
【问题描述】:

我对在引导标签输入中的列表中预定义项目有疑问。 例如。 var city_list = ['苏门答腊','爪哇','苏拉威西'] var city_choosen = ['苏门答腊']

当页面打开时,我想用苹果预定义输入,但在文档中方法 .add 导致“苏门答腊”重复。 我想从现有列表中定义它,而不是添加新列表。

谢谢。

var tagInput = $('#inputCity');
    tagInput.tagsinput({
        itemValue: 'id',
        itemText: 'name',
        typeaheadjs: {
            autoselect: true,
            name: 'cities',
            displayKey: 'name',
            source: cities.ttAdapter()
        }
    })

tagInput.tagsinput('add', {"id":  2, 'name': "Sumatra Utara"});

【问题讨论】:

    标签: typeahead.js bloodhound bootstrap-tags-input


    【解决方案1】:

    我找到了我的错误的解决方案。 在我的 php 代码中,我将引号放在 id 值中,所以它会重复,例如:2 和 '2'。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-02
      • 1970-01-01
      • 2022-12-01
      • 1970-01-01
      • 2022-12-27
      • 1970-01-01
      • 2022-11-20
      相关资源
      最近更新 更多