Bootstrap tagsinput add tag with id and value

后端 未结 5 1310
轮回少年
轮回少年 2021-01-01 23:58

I am using Bootstrap Tags Input

I am trying to add tags dynamically.

$(\'.div-tag\').tagsinput(\'add\', \'vino\');

The above code

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-02 00:44

    initialize tags input like

     $('.div-tag').tagsinput({
          allowDuplicates: false,
            itemValue: 'id',  // this will be used to set id of tag
            itemText: 'label' // this will be used to set text of tag
        });
    

    To add dynamic tag

    $('.div-tag').tagsinput('add', { id: 'tag id', label: 'tag lable' });
    

    That's it;

提交回复
热议问题