How we can get the ID of selected tags using Jquery tagit?

后端 未结 3 993
深忆病人
深忆病人 2020-12-19 14:23

I have a input tag field ,and I want to get the ID of the selected tages So I have try http://jsfiddle.net/u8zj5/19/ But my problem I want to get the id not label or value t

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-19 14:56

    I had the same problem and I what did was modify tag-it.js. When you call the function select you need to send the ID through the function _addTag

    self._addTag(ui.item.label, ui.item.value, ui.item.id);
    

    Then youu just need to get the id:

    _addTag: function(label, value, id) {
        ...
        this._addSelect(label, value, id);
        ...
    }
    

    And here append the ID on a hidden Select

    _addSelect: function(label, value, id) {
            var opt = $('

    With this you can have, one label for the autocomplete list, one value to show in the tag, and the ID on a hidden select.

提交回复
热议问题