Hi there,
I'm really not a JavaScript genius or anything so please bare with me.
I am using a jQuery plugin called "tinySort" that allows you to sort items for example in an unordered list (it's rather nice!). Doing so, you simply call the following code:
$("ul#list > li").tsort("a[title]",{orderby:"title",order:"asc"});
This code sorts my list items by their attribute (title) and orders it by ASC.
This is simple enough, however, I'd like to have multiple links that the user can click which will allow them to sort in many ways on the same list.
The HTML in question for the above code was like this:
<li><a href="#" title="2007">2007</a></li>
But I would like to insert into the title attribute, further parameters which could be used like named value pairs in a query string.
For example, I would like my HTML to be something like:
<li><a href="#" title="date:2007;name:Matt;age:22">2007</a></li>
So I need tinySort to allow me to grab the value I choose (say 'age') and sort by that.
I guess this would require some regex work?
I can achieve my desired effect by using tinySort in the normal way but by using invalid HTML attributes like so:
<li><a href="#" name="Matt" date="2007" age="22">2007</a></li>
But I don't want to do that because it's invalid and very dirty. I would only use this in my moment of desperation! So I need one attribute (possibly rel="" rather than title, that I can load with multiple parameters).
Apologies if I'm not explaining myself well but I'm happy to clarify a few things should you need me to.
Many thanks for your help.
Mikey.