Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

jquery3でtag-itが動かない!

rails5でjquery3を利用していたのですが、tag-itが動きませんでした。

どうやら、jquery3からandSelf()がなくなったことが原因らしいです。
tag-it Githubの該当issue
tag-it.jsのandSelf()部分をaddBack()に書き換えれば動きます。

tag-it.js()
 _create: function() {
            // for handling static scoping inside callbacks
            var that = this;

            // There are 2 kinds of DOM nodes this widget can be instantiated on:
            //     1. UL, OL, or some element containing either of these.
            //     2. INPUT, in which case 'singleField' is overridden to true,
            //        a UL is created and the INPUT is hidden.
            if (this.element.is('input')) {
                this.tagList = $('<ul></ul>').insertAfter(this.element);
                this.options.singleField = true;
                this.options.singleFieldNode = this.element;
                this.element.addClass('tagit-hidden-field');
            } else {
                this.tagList = this.element.find('ul, ol').addBack().last();#ここ

ファイルの124行目に一箇所だけあります。

fujimorichihiro
Ruby on Rails、初学者です。 学習の中で、他の方の役に立ちそうだと思ったものを上げていこうと思います。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away