jQuery UI: sortable('toArray') returns an empty array

后端 未结 7 672
青春惊慌失措
青春惊慌失措 2021-02-01 17:28

This has me stumped. The follow code returns \",,,,,,\":



        
7条回答
  •  有刺的猬
    2021-02-01 17:57

    I was having this issue as well except i did have id's on my elements, jQuery's sortable('toArray') was very hit an miss on return the ids, however you can grab them in javascript using this:

    function getSortOrder() {
        var children = document.getElementById('sortedElement').childNodes;
        var sort = "";
        for (x in children) {
            sort = sort + children[x].id + ",";
        }
        return sort;
    }
    

    This of course returns the ID's in a comma delimited string but you can return the array. I'm sure there's a better way to solve this problem, this is just the solution i found.

提交回复
热议问题