我编写了这个函数来使列可排序。我想重新排列与特定订单号相关联的 div。它在 chrome 和 firefox 中运行良好,但由于某种原因在 IE8 中,而不是在函数的末尾,将所有重新排列的内容附加到#current_orders_content2
div 中,所有内容都消失了。该函数在 JSlint 中检出(通过 jsfiddle),奇怪的是查看最后的所有值(通过 IE 控制台),一切看起来都很好——值是我所期望的。只是似乎append()
失败了。所以我用 进行了测试.html()
,appendTo
但仍然没有喜悦。如果我向它传递一个 html 字符串,它就可以工作,但是这些 jquery 对象失败了。
关于为什么或如何使它工作的任何想法?
谢谢!
$('.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]);
}
}
});