Reputation: 1459
I'm simply trying to get this script to work that I found over here: http://jsfiddle.net/MJ9Zw/ It does not sort.
<!DOCTYPE html> <html lang="en">
<head> <script
type="text/javascript"
src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
var table = $('table');
$('#facility_header, #city_header')
.wrapInner('<span title="sort this column"/>')
.each(function(){
var th = $(this),
thIndex = th.index(),
inverse = false;
th.click(function(){
table.find('td').filter(function(){
return $(this).index() === thIndex;
}).sortElements(function(a, b){
return $.text([a]) > $.text([b]) ?
inverse ? -1 : 1
: inverse ? 1 : -1;
}, function(){
// parentNode is the element we want to move
return this.parentNode;
});
inverse = !inverse;
});
});
</script>
</head>
<body>
<table>
<tr>
<th id="facility_header">Facility name</th>
<th>Phone #</th>
<th id="city_header">City</th>
<th>Speciality</th>
</tr>
<tr>
<td>CCC</td>
<td>00001111</td>
<td>Amsterdam</td>
<td>GGG</td>
</tr>
<tr>
<td>JJJ</td>
<td>55544444</td>
<td>London</td>
<td>MMM</td>
</tr>
<tr>
<td>AAA</td>
<td>33332222</td>
<td>Paris</td>
<td>RRR</td>
</tr>
</table>
</body>
</html>
Edit: I know this looks silly, but I have been staring at this for a couple hours. I know I am missing something obvious, but I have know idea where it is. I have tried two or three different jQuery libraries, but that did not fix it. I have copied it half a dozen times. I apologize in advance for pasting the whole thing, but I am not seeing it. I know I am missing something very obvious.
Upvotes: 1
Views: 167
Reputation: 272236
Did you add:
<script type='text/javascript' src="http://github.com/jamespadolsey/jQuery-Plugins/raw/master/sortElements/jquery.sortElements.js"></script>
to your page?
Tip: try adding /show
to Fiddle URLs, view source and copy.
Upvotes: 1
Reputation: 14873
You're missing the include of the jquery.sortElements.js
script, which you can see registered in the jsfiddle page under "manage resources" section on the left.
Upvotes: 4