I wrote this function to make columns sortable. I want to rearrange divs based that are associated on a particular order number. It works fine in chrome and firefox, but for some reason in IE8 instead of, at the end of the function, appending all the rearranged content to a the #current_orders_content2
div, all of the content simply disappears. The function checks out in JSlint (via jsfiddle) and what's curious is that looking at all the values at the end (via IE console), everything looks all right—values are what I would expect them to be. It just seem that the append()
fails. So I tested with .html()
, appendTo
and still no joy. It works if I pass it an html string, but is failing with these jquery objects.
Any ideas on why or how i can make it work?
Thanks!
$('.sortable').click(function () {
"use strict";
if ($(this).hasClass('sortable_numeric')) {
/*
*function sets ascending/descending classes
*for formatting, placement of arrow_up.png, arrow_down.png
*returns the sort order to be used below "asc" or "desc"
*/
var sort_order = sort_class_distribution($(this));
var current_val = "";
var order_number = "";
/*
*determine what column is being sorted
*remove the "_header" text from the id to
*get this information
*/
var sort_column = this.id;
sort_column = sort_column.replace("header_", "");
/*
*append "_div" to the end of the string to get
*the class of the divs we are sorting by
*/
sort_column += "_div";
var valuesArr = [];
$('.' + sort_column).each(function () {
var current_val = $.trim($(this).text());
current_val = parseInt(current_val, 10);
valuesArr.push(current_val);
});
var sorted = [];
if (sort_order == "asc") {
sorted = valuesArr.slice(0).sort(sortA);
} else if (sort_order == "desc") {
sorted = valuesArr.slice(0).sort(sortD);
}
/*
* for each item in this array, get the parent div
* with the class order_and_lines_container_div.
*
* push it into an array of its own to to put back
* onto the page in the order of the sorted array
*/
var containerArr = [];
var current_container = "";
var c = 0;
for ( c = 0; c <= sorted.length; c++ ) {
current_container = $('#order_container_' + sorted[c]);
containerArr.push(current_container);
}
$('#currentOrdersContent2').html('');
for ( c = 0; c <= sorted.length; c++ ) {
$('#currentOrdersContent2').append(containerArr[c]);
}
}
});