我在Noconflict mod中将Jquery与其他库(Jquery Ui,prototype js,protoplasm)一起使用,并且一切运行良好,直到我决定使用Bootstrap Tokenfield添加基于jui ui的搜索系统
我正在尝试使用Jquery Ui实现this(我更喜欢jquery Ui版本,因为我已经在我的网站上运行了它),但是当我添加代码时
$('#tokenfield').tokenfield({
autocomplete: {
source: ['red','blue','green','yellow','violet','brown','purple','black','white'],
delay: 100
},
showAutocompleteOnFocus: true
})
到我的noconflict代码,我得到错误TypeError:$(...)。tokenfield不是Firebug中的函数,并且假定执行Bootstrap tokenfield类型的自动完成的代码不再起作用
在Chrome中,
未捕获的TypeError:未定义不是函数standard_a.php:174
(匿名函数)jquery-2.1.3.min.js:2
n.Callbacks.jjquery-2.1.3.min.js:2
n.Callbacks.k.fireWithjquery-2.1.3.min.js:2
n.extend.readyjquery-2.1.3.min.js:2我
请如何解决?谢谢
最佳答案
如果您将Jquery与其他库一起使用,则将Jquery置于noconflict模式,并打开bootstrap-tokenfield.js并通过向其添加以下代码将其置于noconflict模式。
jQuery( document ).ready(function( $ ) {
// put this at the very beginning of bootstrap-tokenfield.js
//And the bootstrap-tokenfield.js code goes here
//Put this code at the end of the file bootstrap-tokenfield.js
});
如果您仍然面临挑战,请根据所使用的内容对Bootstrap.js或bootstrap.min.js执行相同的操作。
那应该做。
关于javascript - 在Bootstrap tokenfield中如何解决TypeError:$(…).tokenfield在noconflict中使用jquery时不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28650780/