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

前端 未结 7 1855
感动是毒
感动是毒 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:33

    The easiest way I've found to solve this problem is to change this line in the tag-it Javascript source:

    that.createTag(ui.item.value);
    

    to

    that.createTag(ui.item.label);
    

    This is part of the Autocomplete section of code starting on line 216 in my editor:

    // Autocomplete.
                if (this.options.availableTags || this.options.tagSource) {
                    this._tagInput.autocomplete({
                        source: this.options.tagSource,
                        select: function(event, ui) {
                           // Lots of comments here
                            if (that._tagInput.val() === '') {
                                that.removeTag(that._lastTag(), false);
                            }
                            that.createTag(ui.item.value);
                            value.
                            return false;
                        }
                    });
                }
    

提交回复
热议问题