Ang*_*ine 10 jquery conflict cakephp scriptaculous prototypejs
有没有办法同时使用jquery和scriptaculous js文件?
我试图实现cakephp框架的自动完成功能,该功能需要js文件,prototype.js,scriptaculous.js,effects.js和controls.js.
我还在我的应用程序中使用JQuery函数,它需要jquery.js文件.
如果我包含jquery.js文件,则自动完成功能不起作用.但我还需要jquery.js文件来实现我的jquery函数.
那么是否有任何方法可以同时使用js文件?
kar*_*m79 22
您需要在jQuery中启用无冲突模式,请参阅:
http://docs.jquery.com/Using_jQuery_with_Other_Libraries
从以上链接:
<html>
<head>
<script src="prototype.js"></script>
<script src="jquery.js"></script>
<script>
jQuery.noConflict();
// Use jQuery via jQuery(...)
jQuery(document).ready(function(){
jQuery("div").hide();
});
// Use Prototype with $(...), etc.
$('someid').hide();
</script>
</head>
<body></body>
</html>
Run Code Online (Sandbox Code Playgroud)
但是,您仍需要加载Prototype for Scriptaculous才能工作.作为一个建议,你可能想要尝试jQuery的自动完成插件,如果你正在(或主要)使用其他库作为自动完成小部件.