“query function not defined for Select2 undefined error”

前端 未结 13 1587
名媛妹妹
名媛妹妹 2020-11-28 04:22

Trying to use Select2 and getting this error on multiple item input/text field:

\"query function not defined for Select2 undefined error\"
13条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 05:05

    I have a complicated Web App and I couldn't figure out exactly why this error was being thrown. It was causing the JavaScript to abort when thrown.

    In select2.js I changed:

            if (typeof(opts.query) !== "function") {
                throw "query function not defined for Select2 " + opts.element.attr("id");
            }
    

    to:

            if (typeof(opts.query) !== "function") {
                console.error("query function not defined for Select2 " + opts.element.attr("id"));
            }
    

    Now everything seems to work properly but it is still logging in error in case I want to try and figure out what exactly in my code is causing the error. But for now this is a good enough fix for me.

提交回复
热议问题