Dan*_*ier 0 javascript jquery select conflict prototypejs
我在Javascript中的功能使用原型工作正常.该函数用于根据另一个字段的选择动态更改选择字段.
var sizes_286 = new Array();
sizes_286.push(new Array(536, 'Pequeno', 1661));
sizes_286.push(new Array(536, 'Médio', 1662));
sizes_286.push(new Array(536, 'Grande', 1663));
sizes_286.push(new Array(536, 'ExtGrande', 1664));
function varianteSelected_286(){
var_id = $('variante_286').getValue();
options = $('tamanho_286').options;
options.length = 1;
sizes_286.each(function(size){
if (size[0] == var_id){
options[options.length] = new Option(size[1], size[2]);
}
});
}
document.observe('dom:loaded', function(){
$('variante_286').observe('change', varianteSelected_286);
});
Run Code Online (Sandbox Code Playgroud)
问题是我开始在我的项目中使用jQuery,从那时起这个函数就停止了工作.我正在使用jQuery(1.3.2)和原型(1.6.1).
Jquery的$函数有时会出现与protoype相同的问题,在这种情况下我们调用一个函数,以便Jquery $函数不与Prototype的函数冲突.
该函数是jquery.noConflict()
请参阅链接:http: //docs.jquery.com/Core/jQuery.noConflict
http://docs.jquery.com/Using_jQuery_with_Other_Libraries