jQuery Tag-It - using a value and label object list

前端 未结 7 1978
感动是毒
感动是毒 2021-02-02 16:58

Just tried the excellent Tag-It! plug-in for jquery (http://aehlke.github.com/tag-it/), but I can\'t get it to work how I would like.

I have an object list like this:

7条回答
  •  眼角桃花
    2021-02-02 17:34

    Here's another workaround (assuming you want to use data-id attribute):

      var clone = $('#tags').clone();
      // important to clone before calling tagit()
      $('#tags').tagit({
         beforeTagRemoved: function(event, ui) {
            var item_id = clone.find('li:contains('+ui.tagLabel+')').data('id');
            // do something with item_id / tag ui
         }
      });
    

    Accompanying HTML:

    • Item A
    • Item B

提交回复
热议问题