jQuery version question: enum plugin (test case included)
jQuery version question: enum plugin (test case included)
rbruch
Posts: 2Questions: 0Answers: 0
Hi, I'm trying to use DataTables and the enum plugin to sort by "times" which include values like "30 minutes" "1 hour" "9 months" etc. The table works as expected except that now that I've added the enum sType to the column, it doesn't sort at all.
I'm suspecting that my version of jQuery is the culprit: I'm stuck on 1.4.4 in a CMS system that relies on that specific version for it's working. The enum code and sorting works on the DataTables live site: http://live.datatables.net/igetej/2/edit#javascript,html,live
Have I messed up something in the code or is this not going to work with jQuery 1.4.4? Thanks!
I'm suspecting that my version of jQuery is the culprit: I'm stuck on 1.4.4 in a CMS system that relies on that specific version for it's working. The enum code and sorting works on the DataTables live site: http://live.datatables.net/igetej/2/edit#javascript,html,live
Have I messed up something in the code or is this not going to work with jQuery 1.4.4? Thanks!
This discussion has been closed.
Replies
I've just updated your example to use jQuery 1.4.4 and it works okay: http://live.datatables.net/igetej/3/edit
I'd maybe guess you are getting a JS error on your real site when you add the plug-in?
Allan
Looking at my generated HTML again, I realized that there is a bunch of white space and some HTML tags in there:
[code]
3.5 days
[/code]
I used the "Numbers with HTML" plugin for inspiration and modified my plugin to the following:
[code]
"enum-pre": function ( a ) {
var x = a.replace( /<.*?>/g, "" );
x = x.replace(/(^\s*)|(\s*$)/gi,"");
x = x.replace(/\n /,"\n");
switch( x ) {
...
[/code]
It is working now. I'm really a javascript newb though, is there a tidier/better way to do this? Thanks again!