Support » Plugin: TablePress - Tables in WordPress made easy » Tablepress datatables JS library functions not working

  • Resolved robhale

    (@robhale)


    Hi, I have found a few similar issues reported but haven’t managed to resolve mine using the solutions and advice given.

    I have only recently noticed that the ability to search, sort etc on table headings has disappeared. I think this is because the datatables js library functions are not available to tablepress. I am running a Genesis theme.

    I’d love to get the functions back as it is a very useful feature of our site as you’ll see here:

    http://www.armidalecyclingclub.org/rroty/

    Any help greatly appreciated

    Thanks, Rob

    https://wordpress.org/plugins/tablepress/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi Rob,

    thanks for your post and sorry for the trouble.

    The DataTables JS functions on that page are not working, because there is another JS script in the page that is causing an error. Due to that, the browser stops executing the remaining JS (including DataTables) entirely.

    From what I can see that happens in the theme’s file /wp-content/themes/prestige/js/jquery.isotope.min.js (for details, please see the JS error log console in the browser), so that I suggest to contact the theme support about this.

    Regards,
    Tobias

    Thread Starter robhale

    (@robhale)

    Thanks Tobias, I will contact the theme supplier as you suggest and post back any resolution. Cheers, Rob

    Thread Starter robhale

    (@robhale)

    The solution probably just relates to the genesis prestige child theme but for completeness there was a conflict with jquery.custom.js which needed the following code removed.

    /*————————————————-*/
    // Mobile Menu
    /*————————————————-*/
    jQuery(‘.nav-primary ul.menu’).mobileMenu({
    defaultText: ‘Navigate to…’,
    className: ‘select-menu’,
    subMenuDash: ‘   –’
    });

    At that point all the rich tablepress functionality reappeared.

    Thanks, Rob

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    Sorry for the long delay. As I was on vacation, I didn’t have a chance to reply earlier.

    Thanks for sharing this! This looks reasonable, and I can see how that fixed it 🙂 Nice find!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

    gmohr

    (@gmohr)

    Hi, I am having the same problem with sorting functions not showing up. I have looked at the JS error log in Firefox but I don’t know how to interpret it. Can you help?

    Thanks!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    The reason for this is that your theme is loading the very old version 1.4.2 of the jQuery library, instead of using the current version that ships with WordPress. For ideas to fix this, please see http://tablepress.org/faq/js-functions-not-working/

    Regards,
    Tobias

    gmohr

    (@gmohr)

    Thank you very much for the help. I found the instructions to load the old jquery in the functions.php instead of in the header. I see a reference to it in two places. Can you tell me which lines I should delete from the following:

    ####################################
    //  JAVASCRIPT FILES
    ####################################
    if ( !is_admin() ) {  // instruction to only load if it is not the admin area
    
    function init_js_files() {
    	    wp_deregister_script( 'jquery' );
    	    wp_register_script( 'jquery', get_bloginfo('template_directory') . '/js/jquery-1.4.2.min.js');
    	}    
    
    	add_action('init', 'init_js_files');
    
    	// register your script location, dependencies and version
    	wp_register_script('jquery-coda-slider', get_bloginfo('template_directory') . '/js/jquery.coda-slider-2.0.js');
    	wp_register_script('jquery-easing', get_bloginfo('template_directory') . '/js/jquery.easing.1.3.js');
    	wp_register_script('jquery-qs', get_bloginfo('template_directory') . '/js/jquery.qs.min.js');
    	wp_register_script('jquery-tools', get_bloginfo('template_directory') . '/js/jquery.tools.min.js');
    	wp_register_script('jquery-accordion', get_bloginfo('template_directory') . '/js/jquery-ui-1.8.6.accordion.min.js');
    	// for accordion
    	wp_register_script('jquery-nivo-slider', get_bloginfo('template_directory') . '/js/jquery.nivo.slider.pack.js');
    	wp_register_script('menu', get_bloginfo('template_directory') . '/js/menu.js');
    	wp_register_script('cufon', get_bloginfo('template_directory') . '/js/cufon.js');
    	wp_register_script('font-bebas', get_bloginfo('template_directory') . '/fonts/Bebas_400.font.js');
    	wp_register_script('font-cicle-semi', get_bloginfo('template_directory') . '/fonts/Cicle_Semi_400.font.js');
    	wp_register_script('font-cicle', get_bloginfo('template_directory') . '/fonts/Cicle_300.font.js');
    	wp_register_script('font-gsans', get_bloginfo('template_directory') . '/fonts/GSans_400.font.js');
    	wp_register_script('top-up', 'http://gettopup.com/releases/latest/top_up-min.js');
    
    	// enqueue the script
    	wp_enqueue_script('jquery-coda-slider');
    	wp_enqueue_script('jquery-easing');
    	wp_enqueue_script('jquery-qs');
    	wp_enqueue_script('jquery-tools');
    	wp_enqueue_script('jquery-accordion');
    	wp_enqueue_script('jquery-nivo-slider');
    	wp_enqueue_script('menu');
    	wp_enqueue_script('cufon');
    	wp_enqueue_script('font-bebas');
    	wp_enqueue_script('font-cicle-semi');
    	wp_enqueue_script('font-cicle');
    	wp_enqueue_script('font-gsans');
    	wp_enqueue_script('top-up');
    }
    
    ####################################
    //  JAVASCRIPT FILES END
    ####################################

    Thanks!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    nice find! Please remove these lines:

    function init_js_files() {
    	wp_deregister_script( 'jquery' );
    	wp_register_script( 'jquery', get_bloginfo('template_directory') . '/js/jquery-1.4.2.min.js');
    }    
    
    add_action('init', 'init_js_files');

    Now, you might actually want to check if there’s an updated version of your theme available, as no theme should be doing this replacement of jQuery with its own version.

    Regards,
    Tobias

    gmohr

    (@gmohr)

    Thanks! I tried that and the table now looks great but the other jquery files (coda-slider, accordion, etc.) are not loading. So, for example, the changing picture on the front page of my site (http://www.mohrcollaborative.com/) is now not changing.

    Do I still need the “init” from the add_action line I deleted? And if so, did it need to be defined first?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    ok, now the problem is that those other JS files that your theme uses use the “wrong” function to access jQuery, namely $(). This is however not recommended in WordPress, as jQuery is used in the “noConflict” mode, where the $() function is turned off in favor of the regular/original jQuery() function.

    The best way to fix this would be to update the JS dependencies in your theme (you could maybe contact the theme developers about this, as their code is using bad practices).
    A dirty workaround might be to add something like

    $ = jQuery;

    to the beginning of the /wp-content/themes/neptune/js/jquery.coda-slider-2.0.js file.

    Regards,
    Tobias

    gmohr

    (@gmohr)

    Thanks. I installed this:
    https://wordpress.org/plugins/jquery-updater/
    and my slider started working again.
    Now if I could just get that fixed header to work.

    gmohr

    (@gmohr)

    Got rid of my top nav on the table pages and table header stays fixed now!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    nice! Great to hear that you found this as a workaround!

    In the long term, you should however try to get this fixed in the theme, so that the theme works with a stock WordPress and uses the correct versions of the JS libraries.

    Best wishes,
    Tobias

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Tablepress datatables JS library functions not working’ is closed to new replies.