동적으로 container.slider (...)를 호출하고 처음으로 호출 될 때만 올바른 모양을 얻습니다. 어떻게 수정해야합니까?동적으로 호출 할 때 JQuery Slider의 값이 올바르게 업데이트되지 않습니다.
업데이트 - 분명히 데모는 문제를 재현하는 빠른 해킹입니다. 문제와 관련이없는 한 글로벌 바 등을 사용하지 마십시오.
생식 (버튼을 눌러 몇 번) :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html style="height: 100%;">
<head>
<title></title>
<link href="styles/themes/ui-lightness/jquery-ui-1.9.0.custom.min.css" rel="stylesheet"
type="text/css" />
<script src="scripts/external/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="scripts/external/jquery-ui-1.9.0.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
//
var longValues = [10, 50, 90];
var shortValues = [50];
var mode;
function setLong() {
$("#c").slider({ orientation: "horizontal", range: false, values: longValues, min: 0, max: 100, step: 1 });
mode = "long";
}
function setShort() {
$("#c").slider({ orientation: "horizontal", range: false, values: shortValues, min: 0, max: 100, step: 1 });
mode = "short";
}
$("#t").on("click", function() {
if (mode == "long") {
console.log("set short");
setShort();
}
else {
console.log("set long");
setLong();
}
});
setLong();
});
</script>
</head>
<body style="height: 100%;">
<div id="c" style="width: 200px; vertical-align: middle;">
</div>
<button id="t">Toggle
</button>
</body>
</html>
당신은 버튼을 클릭하면 추가하고 핸들이 제거하려고합니까? – adeneo
아니요. 같은 컨테이너에 다른 슬라이더를 렌더링하려고합니다. – user1514042
글쎄, 다음과 같이 할 수 있습니다 -> [** FIDDLE **] (http://jsfiddle.net/qAweP/) ... – adeneo