1
사용자가 드래그를 시작하자마자 드래그 가능한 요소의 위치를 수정해야하는 이상한 상황이 있습니다. 그래서 draggable 요소의 start 이벤트 핸들러에서 위치를 설정하려고합니다. 그것은 위치 변경에 반응하지 않습니다 - 그리고 이것이 이상한 경우 - 위치를 변경 한 후에 자바 스크립트 오류가 발생합니다. 다음은 그 예입니다.JQuery UI Draggable 요소의 start 이벤트 핸들러에서 CSS 위치 변경을 적용하려면 어떻게해야합니까?
<html>
<head>
<title>Drag reposition test</title>
<script type="text/javascript" src="js/css_browser_selector.js"></script>
<script type="text/javascript" src="development-bundle/jquery-1.3.2.js"></script>
<script type="text/javascript" src="development-bundle/ui/jquery-ui-1.7.1.custom.js"></script> <!-- Includes JQuery UI Draggable. -->
<style type="text/css">
#draggable { width: 150px; height: 150px; padding: 0.5em; }
</style>
<script type="text/javascript">
$(function() {
$("#initialdragger").draggable({
start: function(e, ui) {
$('#initialdragger').css('top', 400);
x = y; // Javascript error, which weirdly causes a redraw.
}
});
});
</script>
</head>
<body>
<div id="initialdragger" class="ui-widget-content" style="border-width: 1px; border-color: black; background-color: orange; width: 300px">
<p>Drag me around</p>
</div>
</body>
</html>
어떻게하면이 상황에서 다시 그리기가 발생합니까? JQuery의 hide() 및 show()는 작동하지 않으며 어느 것도 수행하지 않습니다. these methods.
를 원하는 걸 얻을 것이다 바인딩 생각합니다. 나는 또한 처음으로 일어나는 것이 필요했기 때문에 언 바인드 콜을 던지면서 돌보아 주었다. – Jim