开发者

jQuery sortable Div's

is it possible to sort direct between two or more div's/boxe's and return the complete data (var order = ...) ?

Online Demo: http://jsbin.com/alegu4

<!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>jQuery Dynamic Drag'n Drop</title>

    <script type="text/javascript" src="http://cdn.jquerytools.org/1.2.5/jquery.tools.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js"></script>

<style>
body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    margin-top: 10px;
}

ul {
    margin: 0;
}

#s1,#s2 {
    float: left;
    width: 400px;
}

#s1 li,#s2 li {
    list-style: none;
    margin: 0 0 4px 0;
    padding: 10px;
    background-color:#00CCCC;
    border: #CCCCCC solid 1px;
    color:#fff;
}

</style>

<script type开发者_Go百科="text/javascript">
$(document).ready(function(){ 

    $(function() {
        $("#s1 ul,#s2 ul").sortable({ opacity: 0.6, cursor: 'move', update: function() {
            var order = $(this).sortable("serialize") + '&action=updateRecordsListings'; 
            //$.post("updateDB.php", order);
            alert(order);                                                            
        }                                 
        });
    });

}); 
</script>

</head>
<body>

    <div id="box">

        <div class="box" id="s1">
            <ul>
                <li id="recordsArray_1">1. Lorem ipsum dolor sit amet, consetetur</li>
                <li id="recordsArray_2">2. Lorem ipsum dolor sit amet, consetetur</li>
                <li id="recordsArray_3">3. Lorem ipsum dolor sit amet, consetetur</li>
                <li id="recordsArray_4">4. Lorem ipsum dolor sit amet, consetetur</li>
            </ul>
        </div>

        <div class="box" id="s2">
            <ul>
                <li id="recordsArray_5">5. Lorem ipsum dolor sit amet, consetetur</li>
                <li id="recordsArray_6">6. Lorem ipsum dolor sit amet, consetetur</li>
                <li id="recordsArray_7">7. Lorem ipsum dolor sit amet, consetetur</li>
                <li id="recordsArray_8">8. Lorem ipsum dolor sit amet, consetetur</li>
            </ul>
        </div>

    </div>

</body>
</html>

Please note it's not the same like my other post - thanks!


Check out my JSFiddle.

http://jsfiddle.net/PbDBU/1/

Basically, I combined the 2 DIVs into one, setting the LI elements with a float attribute. Then, I simply Staggered the results like 1,5,2,6,3,7,4,8 instead of 1,2,3,4,5,6,7,8

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜