javascript - nestedsortable.js toarray not working - Stack Overflow

This is my first use of nestedsortable.js in a custom cms creation with codeigniter, So I use it with C

This is my first use of nestedsortable.js in a custom cms creation with codeigniter, So I use it with Codeigniter php framework. I have an ordered and nested list(for order pages) and I need to convert this list to array with 'toArray' but it's not working the error message: uncaught typeError: Cannot call method 'match' of undefined this is my js code:

<script>
$(document).ready(function(){
    $.post('<?=base_url("index.php/admin/pages/order_ajax"); ?>',{},function(data){
        $('#orderResult').html(data);
    });
    $('#save').click(function(){
        oSortable = $('.sortable').nestedSortable('toArray');
        $.post('<?=base_url("index.php/admin/pages/order_ajax"); ?>',{sortable:oSortable},function(data){
            $('#orderResult').html(data);
        });
    });

});

except that everything is good, so I need your help

This is my first use of nestedsortable.js in a custom cms creation with codeigniter, So I use it with Codeigniter php framework. I have an ordered and nested list(for order pages) and I need to convert this list to array with 'toArray' but it's not working the error message: uncaught typeError: Cannot call method 'match' of undefined this is my js code:

<script>
$(document).ready(function(){
    $.post('<?=base_url("index.php/admin/pages/order_ajax"); ?>',{},function(data){
        $('#orderResult').html(data);
    });
    $('#save').click(function(){
        oSortable = $('.sortable').nestedSortable('toArray');
        $.post('<?=base_url("index.php/admin/pages/order_ajax"); ?>',{sortable:oSortable},function(data){
            $('#orderResult').html(data);
        });
    });

});

except that everything is good, so I need your help

Share Improve this question asked Sep 25, 2013 at 9:40 user2814542user2814542 112 bronze badges 3
  • Couldn't you use: oSortable = $('.sortable').get(); – A. Wolff Commented Sep 25, 2013 at 9:44
  • not working, the toarray get the list as a nested array.I need this array to continue the other proccesses – user2814542 Commented Sep 25, 2013 at 10:25
  • 1 Maybe you should provide what you get and what you expect to get... – A. Wolff Commented Sep 25, 2013 at 10:29
Add a ment  | 

1 Answer 1

Reset to default 9

I had the same problem. The solution is simple. You need set id for your li elements.

<li id="list_1"> etc... 

Because without a set id, element returns "undefined" and it throws an error. Function "match" needs string.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745090723a4610679.html

相关推荐

  • javascript - nestedsortable.js toarray not working - Stack Overflow

    This is my first use of nestedsortable.js in a custom cms creation with codeigniter, So I use it with C

    14小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信