diff --git a/Source/Interface/HtmlTable.Sort.js b/Source/Interface/HtmlTable.Sort.js
index 3a488ba9..cb75dcee 100644
--- a/Source/Interface/HtmlTable.Sort.js
+++ b/Source/Interface/HtmlTable.Sort.js
@@ -13,6 +13,7 @@ authors:
- Harald Kirschner
- Aaron Newton
- Jacob Thornton
+ - Henning Bopp
requires:
- Core/Hash
@@ -95,8 +96,7 @@ HtmlTable = Class.refactor(HtmlTable, {
if (cell.hasClass(this.options.classNoSort) || cell.retrieve('htmltable-parser')) return cell.retrieve('htmltable-parser');
var thDiv = new Element('div');
thDiv.adopt(cell.childNodes).inject(cell);
- var sortSpan = new Element('span', {'class': this.options.classSortSpan}).inject(thDiv, 'top');
- this.sortSpans.push(sortSpan);
+ this.getHeadSpan().inject(thDiv, 'top');
var parser = this.options.parsers[index],
rows = this.body.rows,
cancel;
@@ -262,6 +262,7 @@ HtmlTable = Class.refactor(HtmlTable, {
this.element.addClass(this.options.classSortable);
this.attachSorts(true);
this.setParsers();
+ this.head && this.head.getElements(this.options.thSelector).flatten().map(this.injectHeadSpan, this);
this.sortable = true;
return this;
},
@@ -275,8 +276,17 @@ HtmlTable = Class.refactor(HtmlTable, {
this.sortSpans.empty();
this.sortable = false;
return this;
- }
+ },
+ getHeadSpan: function(parent){
+ var sortSpan = new Element('span', {'class': this.options.classSortSpan});
+ this.sortSpans.push(sortSpan);
+ return sortSpan;
+ },
+
+ injectHeadSpan: function(parent){
+ return this.getHeadSpan().inject(parent);
+ }
});
HtmlTable.ParserPriority = ['date', 'input-checked', 'input-value', 'float', 'number'];
@@ -358,4 +368,3 @@ HtmlTable.defineParsers = function(parsers){
};
})();
-