众所周知,Discuz!X拥有自己的JS类,当我们需要添加更好的网页动画效果就需要使用到JQuery等框架。那么,在开发Discuz!X前台的同时,如何将JQuery完美兼容至Discuz!X呢?网上也有几种解决办法!
第一步:在 JQuery官方 下载放到 ./static/js 目录下;
第二步:查找 ./template/default/common/header_common.htm,在第 17行
<!--{csstemplate}-->的后面,添加代码:
<script src=\"{$_G[setting][jspath]}jquery.js?{VERHASH}\" type=\"text/javascript\"></script>
第三步:在使用到 JQuery的$的地方用jQuery代替。
示例 JQuery 代码:
$(document).ready(function(){
$(\"#scbar\").stop().animate({right: \"300px\"},{queue:false, duration:3000, easing: 'easeOutBounce'})
}
替换为:
jQuery(document).ready(function(){
jQuery(\"#scbar\").stop().animate({right: \"300px\"},{queue:false, duration:3000, easing: 'easeOutBounce'})
}