4
안녕하세요 저는 jquery를 처음 사용하고 프로그래머도 아닙니다.
Google에서 답변을 검색하려고했지만 답변을 찾을 수 없습니다.
여기에 내 의지가 있습니다, 나는 "sort"버튼을 클릭 한 후에 만 정렬 할 항목 목록을 가지고 있습니다. 항목의 목록을 정렬 할 수 없어야합니다. "확인"버튼을 클릭하십시오.
제 스크립트가 작동하지 않습니다. 아무도 도와 줄 수 있습니까?
벤 jquery ui sortable - 트리거되는 경우 정렬 할 수 없게하는 방법?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>sortable test</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("jquery", "1.3.2");google.load("jqueryui", "1.7.1");</script>
<style type="text/css">
#sortable {
list-style-type: none;
margin: 0;
padding: 0;
width: 100%;
}
#sortable li {
padding: 5px;
font-size: 1.2em;
height: 1.5em;
background:#ccc;
border:1px #333 solid;
}
html>body #sortable li {
height: 1.5em;
line-height: 1.2em;
}
.ui-state-highlight {
height: 1.5em;
line-height: 1.2em;
background:#ffcc33!important;
border:1px #ff6600 solid!important;
}
.demo{
width:200px;
margin:0 auto;
}
.btn{
background:#ffcc33;
border:3px #ff6600 dashed;
color:#FFF;
cursor:pointer;
margin:5px 0;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
function sort(){
$("#sortable").sortable({
placeholder: 'ui-state-highlight'
});
$("#sortable").disableSelection();
}
$('#sort').bind('click',sort);
$('#confirm').bind('click',sort);
});
</script>
</head>
<body>
<div class="demo">
<div id="sort" class="btn">Sort</div>
<div id="confirm" class="btn">Confirm</div>
<ul id="sortable">
<li class="ui-state-default">Item 1</li>
<li class="ui-state-default">Item 2</li>
<li class="ui-state-default">Item 3</li>
<li class="ui-state-default">Item 4</li>
<li class="ui-state-default">Item 5</li>
<li class="ui-state-default">Item 6</li>
<li class="ui-state-default">Item 7</li>
</ul>
</div>
</body>
</html>
Woooo 빨리! 감사합니다. 그것은 마치 매력처럼 작동합니다! – ben
나는 버튼 "sort"가 buttun "confirm"이 클릭 된 후, "sort"버튼이 더 이상 기능 할 수 없기 때문에 한번만 실행할 수 있다는 것을 알았습니다. 그래서 "sort"함수와 그 작업 재미로 코드를 추가합니다 :)
– ben