“query function not defined for Select2 undefined error”

前端 未结 13 1568
名媛妹妹
名媛妹妹 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:00

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

    This is thrown becase query does not exist in options. Internally there is a check maintained which requires either of the following for parameters

    • ajax
    • tags
    • data
    • query

    So you just need to provide one of these 4 options to select2 and it should work as expected.

提交回复
热议问题