5步解決Ecshop與Jquery沖突 處理加入購物車無效問題
2024-07-09 22:56:58
供稿:網友
1、修改文件:/js/transport.js
在文件最底部增加代碼:
if (Object.prototype.toJSONString){ var oldToJSONString = Object.toJSONString; Object.prototype.toJSONString = function(){ if (arguments.length > 0){ return false; }else{ return oldToJSONString.apply(this, arguments); } } }
2、修改文件:/js/compare.js
查找代碼:
this.timer = window.setInterval(this.relocation.bind(this), 50);
修改為:
this.timer = window.setInterval(this.bind(this.relocation,this), 50);
查找代碼:
lastScrollY : 0
在代碼上面一行增加代碼:
bind : function(obj1,obj2) { return function() { obj1.apply(obj2, arguments); } },
3、在以下模板文件中,找到嵌入global.js文件的代碼,刪除嵌入global.js
brand.dwt
brand_list.dwt
category.dwt
exchange_list.dwt
search.dwt
4、下載最新版的jquery庫文件到模板目錄中,如:
/themes/temlatename/images/js/jquery.1.5.2.js
如果你的模板中沒有對應目錄,則新建目錄拷入jquery文件即可
5、修改文件:/themes/temlatename/library/page_header.lbi
在頂部加入代碼:
<script src="images/js/jquery.1.5.2.min.js" type="text/javascript"></script>
<script type="text/javascript">var $$=jQuery.noConflict();</script>
注意,以后調用JQUERY對象要用兩個美元符$$,不要用一個$,因為一個$與ECSHOP原有的函數同名有兼容問題。
6、修改完畢!放心使用你的JQUERY特效吧