Better way to call this function?

I have the following at the end of my markup stack:

window.onload = function(){list_resize('test');};
window.onresize = function(){list_resize('test');};

The function “list_resize” is exactly what it implies: it resizes a UL based on whether or not the UL is bigger than the parent element containing it. I placed it inside an onload and onresize event to synthesize a constant state of being ran, but I would like to make it easier to pass arguments to as setting more and more calls inside the above functions isn’t very practical.

Any suggestions? The argument is the ID of a given UL. :confused:

You could make he function capable of handling an array of id’s, so that you can store a list of them in a globally accessible variable

function list_resizeItems(items) {
    var i;
    for (i = 0; i < items.length; i += 1) {

window.resizeList = [];

window.onresize = function () {

Then you can push more items on to window.resizeList at any time you want, or use splice to remove one of them.

For example, if you had:
window.resizeList = [‘test’, ‘this’, ‘that’, ‘other’];

Then to remove the middle one, at index 2, you would use:
window.resizeList.splice(2, 1)

Which results in the ‘that’ one being removed, leaving you with
[‘test’, ‘this’, ‘other’]