jQuery version question: enum plugin (test case included)

jQuery version question: enum plugin (test case included)

rbruchrbruch Posts: 2Questions: 0Answers: 0
edited December 2012 in DataTables 1.9
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!

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    edited December 2012
    DataTables should currently work just fine with 1.4.4 (although v1.10 might require v1.5 or 1.6 - haven't yet decided!).

    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
  • rbruchrbruch Posts: 2Questions: 0Answers: 0
    Thanks for your response.

    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!
This discussion has been closed.