So, after an AJAX call, I add the following, and this AJAX call can happen several times, returning multiple data items. And I'm trying to use Tinysort [ http://plugins.jquery.com/project/TinySort] to sort the list every time, so the added new items are perfectly combined and sorted alphabetically.
Unfortunately, it does not seem to work. Any ideas? I mean, the data itself is correctly added, but, unfortunately, sorting does not occur.
var artists = []; $.each(data.artists, function(k, v) { artists.push('<section id="artist:' + v.name + '" class="artist"><div class="span-9"><img alt="' + v.name + '" width="34" height="34" class="photo" src="' + v.photo + '" /><strong>' + v.name + '</strong><br/><span>' + v.events + ' upcoming gig'); if (v.events != 1) { artists.push('s'); } artists.push('</span></div><div class="span-2 align-right last">Last</div><div class="clear"></div></section>'); }); $('div.artists p').remove(); $('div.artists div.next').remove(); $('div.artists').append(artists.join('')).append('<div class="next"><a href="#">Next</a></div>'); $('div.artists section').tsort('section[id]', {orderby: 'id'});
Thanks!
jquery
James
source share