Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
Javascript Sortablejs Serialize

I have function serialize for sortablejs to want result like ['1','2','3','4','5','6','7','8','9','10','11'], and i already try 2 time push array with example function

function serialize(sortable, type, groupIndex = 0) {
    let typeQuery = '';

    if (typeof type === 'undefined' || type === 'group') {
        typeQuery = '.menu-nested';
    } else if (type === 'main') {
        if (typeof groupIndex !== 'undefined' && typeof groupIndex === 'number') {
            var removeVar = '',
                regexMenuGroup = $('div[id*="managegroup-"][data-id="'+groupIndex+'"]'),
                idMenuGroup = regexMenuGroup.attr('id');
    
            removeVar = groupIdMenu[idMenuGroup];
        }

        typeQuery = ''+removeVar;
    }

    var serialized = [],children = [].slice.call(sortable.children);

    for (var i in children) {
        var nested = children[i].querySelector('.menu-nested');

        serialized.push(children[i].dataset[identifier.id]);
        serialized.push(nested ? serialize(nested, 'group') : []);
    }

    return serialized;
}

But result not as expected

[
    "1",
    [],
    "2",
    [
        "3",
        [],
        "4",
        [],
        "5",
        [],
        "6",
        [],
        "7",
        [],
        "8",
        [],
        "9",
        [],
        "10",
        [],
        "11",
        []
    ]
]

Can concat provide this case?

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!