TypeError:o.element 未定义 - jquery ui
2017-06-23
2970
我正在使用
jquery-ui
。两周后我仍无法解决这个问题。
我不知道为什么点击滑块后会出现此错误:
控制台 Firefox:
TypeError: o.element is undefined[Learn More] jquery-ui.min.js:6:6058
控制台 chrome:
jquery-ui.min.js:6 Uncaught TypeError: Cannot read property 'toggleClass' of undefined
at t.(anonymous function).(anonymous function)._toggleClass (http://localhost:8000/assets/frontend/_js/jquery-ui.min.js:6:6067)
at t.(anonymous function).(anonymous function)._addClass (http://localhost:8000/assets/frontend/_js/jquery-ui.min.js:6:5877)
at t.(anonymous function).(anonymous function)._mouseCapture (http://localhost:8000/assets/frontend/_js/jquery-ui.min.js:6:14171)
at t.(anonymous function).(anonymous function)._mouseCapture (http://localhost:8000/assets/frontend/_js/jquery-ui.min.js:6:1111)
at t.(anonymous function).(anonymous function)._mouseDown (http://localhost:8000/assets/frontend/_js/jquery-ui.min.js:6:9414)
at t.(anonymous function).(anonymous function)._mouseDown (http://localhost:8000/assets/frontend/_js/jquery-ui.min.js:6:1111)
at HTMLDivElement.<anonymous> (http://localhost:8000/assets/frontend/_js/jquery-ui.min.js:6:8701)
at HTMLDivElement.dispatch (http://localhost:8000/assets/frontend/_js/jquery-3.1.1.min.js:3:10315)
at HTMLDivElement.q.handle (http://localhost:8000/assets/frontend/_js/jquery-3.1.1.min.js:3:8342)
<script type="text/javascript" src="http://localhost:8000/assets/frontend/_js/jquery-3.1.1.min.js"></script>
<!-- http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js -->
<script type="text/javascript" src="http://localhost:8000/assets/frontend/_js/bootstrap.min.js"></script>
<!-- https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js -->
<script type="text/javascript" src="http://localhost:8000/assets/frontend/_js/jasny-bootstrap.min.js"></script>
<script type="text/javascript" src="http://localhost:8000/assets/frontend/_js/bootstrap-select.min.js"></script>
<script type="text/javascript" src="http://localhost:8000/assets/frontend/_js/persian-datepicker.min.js"></script>
<script type="text/javascript" src="http://localhost:8000/assets/frontend/_js/script.js"></script>
<script type="text/javascript" src="http://localhost:8000/assets/frontend/_js/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://localhost:8000/assets/frontend/_js/jquery.ui.touch-punch.min.js"></script>
<script>
$(document).ready(function(){
$( "#slider" ).slider({
range: true,
min: -10000000,
max: -1000,
values: [ -8000000, -2000 ],
slide: function(event, ui) {
$(".amount .min-price").text(addCommas (ui.values[1]*-1) + " ریال ");
$(".amount .max-price").text(addCommas (ui.values[0]*-1) + " ریال ");
}
});
$(".amount .min-price").text(addCommas ($("#slider").slider( "values", 1 )*-1 ) + " ریال ");
$(".amount .max-price").text(addCommas ($("#slider").slider( "values", 0 )*-1 ) + " ریال ");
// Hover states on the static widgets
$( "#dialog-link, #icons li" ).hover(
function() {
$( this ).addClass( "ui-state-hover" );
},
function() {
$( this ).removeClass( "ui-state-hover" );
}
);
});
</script>
我的 HTML 代码:
<div class="col-md-12">
<div id="slider" class="ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content">
<div class="ui-slider-range ui-corner-all ui-widget-header">
</div>
<span tabindex="1" class="ui-slider-handle ui-corner-all ui-state-default">
</span>
<span tabindex="2" class="ui-slider-handle ui-corner-all ui-state-default" >
</span>
</div>
</div>
//used in slider
function addCommas(nStr){
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
我的网站地址:
http://tahrircenter.com/products
我删除了多余的代码,但仍然出现同样的错误:
它在
jsfiddle
上运行良好!!!:
https://jsfiddle.net/Twisty/3gm3sfem/
.toggleClass() is a function of jQuery, so if you're getting an error that it's undefined, then it's possible another version of jQuery may be loaded elsewhere. Or it's not being loaded at all.
1个回答
我遇到了这个问题,并解决了它。
我不小心将滑块设置为未定义的值。 此时,没有产生任何错误。
但是,当我稍后尝试移动滑块时,我收到错误 o.element 未定义。
当我将滑块设置为一个合适的值时,问题就消失了。
jane
2019-05-31