I am attempting to use the Select2 library in my site to leverage placecomplete
(following it's rather simple configuration steps here), but when I run the code I get a strange error -
我正在尝试在我的站点中使用Select2库来利用placecomplete(以下是相当简单的配置步骤),但是当我运行代码时,我得到了一个奇怪的错误-
Error: No select2/compat/query`
错误:没有select2 /兼容/查询”
I've tried googling it and it really seems like no one else has encountered this?
我试过用谷歌搜索,好像没人碰到过这个?
My code in a nutshell is,
简单地说,我的代码是,
loading the files...
加载文件…
<link href="scripts/Select2/dist/css/select2.min.css" rel="stylesheet" />
<script src="scripts/Select2/dist/js/select2.min.js"></script>
<script src="scripts/jquery.placecomplete.js">//<![CDATA[//]]></script>
Tagging an input element in my body...
给我身体里的输入元素加上标签……
<input id="example123" class="example123" type="text" />
In my document.ready function, calling the following code...
在我的文档。就绪函数,调用以下代码…
$('#example123').placecomplete({});
and thats where it throws the error.
这就是它抛出错误的地方。
Any ideas where Im going wrong, and what this error means?
你知道我哪里出错了吗?这个错误意味着什么?
2 个解决方案
#1
67
You are running into two issues here, both of which can easily be fixed.
您在这里遇到了两个问题,这两个问题都很容易解决。
-
Select2 4.0.0 no longer supports the
query
option in the slimmed down, standard build. This must be included in the full build (select2.full.js
) as it is handled through a backwards compatibility module.Select2 4.0.0不再支持精简的标准构建中的查询选项。这必须包含在完整的构建(select2.full.js)中,因为它是通过向后兼容模块处理的。
-
You are using Placecomplete and it depends on an older version of Select2. It looks like Select2 3.5.2+ can work, but I can tell from the options that it is using, it cannot work with Select2 4.0.0. There is an open ticket about this for Placecomplete.
您正在使用Placecomplete,它依赖于Select2的旧版本。它看起来像Select2 3.5.2+可以工作,但是我可以从它使用的选项中看出,它不能使用Select2 4.0.0。这里有一张免费的机票。
#2
9
I've had this when you have two controls on your web page with the same Id - I had a hidden control and a select (the hidden control was first).
当您的web页面上有两个相同Id的控件时,我就有了这个——我有一个隐藏控件和一个select(隐藏控件是第一个)。
#1
67
You are running into two issues here, both of which can easily be fixed.
您在这里遇到了两个问题,这两个问题都很容易解决。
-
Select2 4.0.0 no longer supports the
query
option in the slimmed down, standard build. This must be included in the full build (select2.full.js
) as it is handled through a backwards compatibility module.Select2 4.0.0不再支持精简的标准构建中的查询选项。这必须包含在完整的构建(select2.full.js)中,因为它是通过向后兼容模块处理的。
-
You are using Placecomplete and it depends on an older version of Select2. It looks like Select2 3.5.2+ can work, but I can tell from the options that it is using, it cannot work with Select2 4.0.0. There is an open ticket about this for Placecomplete.
您正在使用Placecomplete,它依赖于Select2的旧版本。它看起来像Select2 3.5.2+可以工作,但是我可以从它使用的选项中看出,它不能使用Select2 4.0.0。这里有一张免费的机票。
#2
9
I've had this when you have two controls on your web page with the same Id - I had a hidden control and a select (the hidden control was first).
当您的web页面上有两个相同Id的控件时,我就有了这个——我有一个隐藏控件和一个select(隐藏控件是第一个)。