Display divs in a specified order
I have a list of checkboxes that a user can select and drag and drop in any order. The selected items and the order that they are in are saved in a cookie value (using a cookie plugin). The function below retrieves the cookie value and loops through the values stored in the cookie and now I want to display only those div sections which are in the cookie and in the same order (this is the part that I'm having trouble with). I have each div with a style of display:none and I could just just the display: value to show them but how do I output them/display them in the same order as the cookie value? I hope this makes sense. Thanks
function
listOrder() {
var list = $(setSelector);
if (list == null) return
// fetch the cookie value (saved order)
var cookie = $.cookie(setCookieName);
if (!cookie) return;
// make array from saved order
var IDs = cookie.split(",");
// fetch current order
var items = list.sortable("toArray");
// make array from current order
var rebuild = new Array();
for (var v = 0, len = items.length; v < len; v++) {
alert(items[v]);
}
}
alert(items[v] produces output like this:
item-4
item-2
item-9
item-1
.....etc. up to item-23
These are the divs I'm trying to place in the order specified by the
<div id="item1" class="hidden"></div>
<div id="item2"></div>
<div id="item3"></div>
<div id="item4"></div>
.....etc. up to item-23