I solved it with the following: var myTextExtraction = function(node) { // extract data from markup and return it if(node.childNodes[0].innerHTML) return node.childNodes [0].innerHTML; else return node.innerHTML; } $(document).ready(function() { // extend the default setting to always include the zebra widget. $.tablesorter.defaults.widgets = ['zebra']; $("table").tablesorter({textExtraction: myTextExtraction}); });
Thanks for the replies and getting my mind thinking! On Oct 29, 9:57 am, Jacob <jste...@gmail.com> wrote: > What I meant by remove the white space is that normally I like to > indent all my code, so I'd have the <td> tag, then hit enter, then tab > in to indent, then have the <a> tag, then potentially hit enter avian > before putting in the text for the link, etc. What I found, though, > was that if I put no spaces or newlines (hitting enter) in the HTML > between the opening <td> and the closing then it would sort properly. > Just my experience. > > On Oct 27, 11:58 am, ChaosAD <chao...@gmail.com> wrote: > > > > > Not entirely sure what you mean by removed all the white space. Could > > you please elaborate. > > > On Oct 27, 11:39 am, Jacob <jste...@gmail.com> wrote: > > > > I recently had the same problem of links sorting by the URL, but I > > > discovered that if I removed all the white space within the cell in my > > > HTML it would sort by the text and not the URL. I don't know if that > > > will help you with <em> tags as well, but it solved the problem for > > > links for me. > > > > On Oct 27, 7:53 am, ChaosAD <chao...@gmail.com> wrote: > > > > > Here is example of table presently working on. I using the code below, > > > > but getting error message: > > > > > $(document).ready(function() { > > > > > // call the tablesorter plugin > > > > $("table").tablesorter({ > > > > // define a custom text extraction function > > > > textExtraction: function(node) { > > > > // extract data from markup and return it > > > > return node.childNodes[0].childNodes[0].innerHTML; > > > > } > > > > }); > > > > > }); > > > > > Error: node.childNodes[0].childNodes[0] is undefined > > > > > Example row: > > > > <td>54</td><td>34</td><td><a hred='something' target='_blank'>blah</ > > > > a></td> > > > > > On Oct 26, 6:55 pm, ChaosAD <chao...@gmail.com> wrote: > > > > > > Thanks, I will tomorrow when back at work. Right now it is data in > > > > > <td> themselves and links inside as well. I want to make it flexable > > > > > though so it can handle other types such as <em> etc. > > > > > > On Oct 26, 6:26 pm, MorningZ <morni...@gmail.com> wrote: > > > > > > > Perhaps post an example of the <table>'s HTML and it would (much) > > > > > > easier to help.... as your first post mentioned <a> tags and you > > > > > > implied it was nothing but those, now you have <em> or no tag at > > > > > > all, > > > > > > quite a bit more complicated now > > > > > > > On Oct 26, 4:45 pm, ChaosAD <chao...@gmail.com> wrote: > > > > > > > > Thanks for the reply. My problem is rising from the fact that not > > > > > > > all > > > > > > > column are url based. Some are straight data and some others might > > > > > > > have other tags such as <em> around them. I tried following the > > > > > > > example for custom parser and I kept getting s integer errors. > > > > > > > Sorry > > > > > > > if this is simple problem, I am very nice to jquery and especially > > > > > > > tablesort. > > > > > > > > On Oct 26, 4:36 pm, MorningZ <morni...@gmail.com> wrote: > > > > > > > > > You'll need to write a custom Parser so that you get what's > > > > > > > > inside the > > > > > > > > <a> tag and not the string itself... > > > > > > > > > It's very easy to do if you just follow his example on the site > > > > > > > > > On Oct 26, 3:00 pm, ChaosAD <chao...@gmail.com> wrote: > > > > > > > > > > I'm fairly new to Tablesort, but got it working for the most > > > > > > > > > part. The > > > > > > > > > only problem I have is any columns that have a <a href></a> > > > > > > > > > in them. > > > > > > > > > It seems to sort it based on the url and not that actual data > > > > > > > > > in the > > > > > > > > > cell. How do I get it to sort based on the data and not the > > > > > > > > > url?