jquery how to make each function to call finally updating all?
<p>i have a function to loop through all the 'li' element and collect the data. as well i am pushing all the data to array. once the all 'li' loop through finish, i need to call a function one time with updated data?</p>

<p>my present code like this: but it calling 3 times my function, because it gets 3 times the condition. the function works fine, i am wrong to call the function, any good suggestion to make it to call one time, after finishing all the loop.</p>

<pre><code>var pieIndex = [];
$('button.pieDraw', $(accordionBox)).live('click', function () { //done button
    var uls = $(accordionSec.accorGeography).find('ul');

    $.each(uls, function (i, val) {
        pieIndex = []; //i am clearing the array each time to get new value
        var currentLI = $(val).find('li');
        $(currentLI).each(function () {
            if ($(this).hasClass('c_on')) { // this is finding the class 3 times. it's fine
                var functionName = pieFunction[$(this).parent().attr('title') + 'Pie'].fun;
                pieIndex.push($(this).attr('data-index')); // at the last i am getting 1,2,3 it's correct.
                generatePieURL(functionName, curQI, crrentMonth, currentYear, pieIndex);
                //it is calling 3 times. i need only one time to call..
            }
        })

    })

});
</code></pre>

<p>thanks in advance.</p>
