我有一个cakePhp网站,我使用原型制作所有ajax的东西,使用jQuery制作动画,......
我已经像这样管理了jquery-prototype问题:
echo $javascript->link('jquery-1.6.2');
echo $javascript->link('jquery.cookie');
echo $javascript->link('jQueryNoConflict');
echo $javascript->link('prototype');
jQuerynoConflict只包含
$.noConflict();
我做了一个小的JS脚本,它显示带有已定义类的项目,并用其他类隐藏其他项目:
if(jQuery.cookie('isRawPrice')==1){
jQuery('.priceWithoutTva').show();
jQuery('.priceWithTva').hide();
}else{
jQuery('.priceWithoutTva').hide();
jQuery('.priceWithTva').show();
}
我在每个页面上工作,除了我有Google地图项目的页面。我这样添加:
function InitMap(elementId, initPosition, initZoom, multiplePolygonsString) {
var pos = initPosition.split(',');
var myLatLng = new google.maps.LatLng(pos[0], pos[1] );
var myOptions = {
zoom:initZoom,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.TERRAIN
};
map = new google.maps.Map(document.getElementById(elementId), myOptions);
var multiplePolygons = multiplePolygonsString.split(';');
for(var i=0;i<multiplePolygons.length;i++){
var currentPolygon,match,coordinates = [];
var reg = /\(\s*([0-9.-]+)\s*,\s*([0-9.-]+)\s*\)/g ;
while((match = reg.exec(multiplePolygons[i]))!==null){
coordinates.push( new google.maps.LatLng(+match[1], +match[2]));
}
currentPolygon = new google.maps.Polygon({
paths: coordinates,
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 3,
fillColor: "#FF0000",
fillOpacity: 0.35
});
currentPolygon.setMap(map);
// Add a listener for the click event
google.maps.event.addListener(currentPolygon, 'click', function(event){ showArrays(event, "testInfoBulle"); });
}
infowindow = new google.maps.InfoWindow();
}
(这基本上加载地图并在定义的区域上创建一些多边形。)。每次显示时都会生成这张地图。
但是当我显示它并尝试使用前面的代码隐藏/显示时,我得到了这个例外:
Uncaught TypeError: Object #<SVGAnimatedString> has no method 'match'prototype.js:300
Enumerable.eachprototype.js:300
Enumerable.injectprototype.js:372
document.getElementsByClassNameprototype.js:932
Sizzlejquery-1.6.2.js:4869
jQuery.fn.extend.findjquery-1.6.2.js:5188
jQuery.fn.jQuery.initjquery-1.6.2.js:189
jQueryjquery-1.6.2.js:27
updateDisplay.js:26 ---> This is the jQuery('.priceWithoutTva').show(); line
(anonymous function)cat3:3000:643
onclickcat3:3000:644
当他在jquery方法中时,为什么它会通过Prototype库???
答案 0 :(得分:0)
是否与您的匹配变量发生冲突,可能是原型或jquery文件中的全局匹配变量或函数?尝试将你的名字改名为更独特的东西,看看会发生什么。
答案 1 :(得分:0)
我有jQuery 1.6.2和原型1.4,我现在更新到jquery 1.6.4和原型1.7并且它正在工作!