• Resolved catalinos

    (@catalinos)


    Hello,

    I’ve noticed that I get an error on the pages where Tablepress inserts a table.

    The error is the next one:

    (index):29 Uncaught TypeError: $(…).dataTable is not a function
    at HTMLDocument.<anonymous> ((index):29)
    at i (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at Function.ready (jquery.min.js:2)
    at HTMLDocument.K (jquery.min.js:2)

    Do you have any suggestion? Thanks!

    Also, I want to suggest an improvement based on the latest comment of John Mueller from Google:

    https://www.searchenginejournal.com/mobile-first-ranking/246749/

    Could you please find a solution to replace the <table> (not SEO friendly) with divs? Thank you!

    • This topic was modified 6 years, 7 months ago by catalinos.
    • This topic was modified 6 years, 7 months ago by catalinos.

    The page I need help with: [log in to see the link]

Viewing 10 replies - 16 through 25 (of 25 total)
  • Thread Starter catalinos

    (@catalinos)

    NOTE: I’ve replaced the version of jquery from 1.8.1 to 1.12.4.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    please remove this function call from your “functions.php” altogether. We need to use the jQuery version that ships with WordPress.
    Even though things don’t work yet after that, it’s the only possible starting point. I assume that after removing the function, we will see other JS errors that we can then fix.

    Regards,
    Tobias

    Thread Starter catalinos

    (@catalinos)

    Hi Tobias,

    Wordpress comes with jQuery 1.12.4 by default. This is what I’ve added.

    Thanks!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    that’s correct, but the WordPress version ships with a very subtle change (jQuery.noConflict();), which we need here.
    If you want me to help you, please trust me and try what I suggest.

    Regards,
    Tobias

    Thread Starter catalinos

    (@catalinos)

    OK, I’ve removed the code then re-added the original one.

    function reassign_jQuery() {
         wp_deregister_script( 'jquery' );
         wp_deregister_script( 'jquery-core' ); // do not forget this
         wp_deregister_script( 'jquery-migrate' ); // do not forget this
    
         wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js', array(), '1.12.4', TRUE );
         wp_enqueue_script('jquery');
    }
    if ( ! is_admin() )
        add_action('init', 'reassign_jQuery');

    This is the error I get:

    Uncaught TypeError: $(...).dataTable is not a function
        at HTMLDocument.<anonymous> ((index):27)
        at i (jquery.min.js:2)
        at Object.fireWith [as resolveWith] (jquery.min.js:2)
        at Function.ready (jquery.min.js:2)
        at HTMLDocument.K (jquery.min.js:2)

    You can test it here: https://antivirus.factsrider.com/best-internet-security-software/

    • This reply was modified 6 years, 7 months ago by catalinos.
    • This reply was modified 6 years, 7 months ago by catalinos.
    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    please remove any of this code. We don’t want to override jQuery with anything. We want to use the version that comes with WordPress, which will happen if there is no such code in the functions.php. Thanks!

    Regards,
    Tobias

    Thread Starter catalinos

    (@catalinos)

    LOL. It’s working!

    The conclusion: the theme’s code was not right.

    Thank you very much Tobias!

    • This reply was modified 6 years, 7 months ago by catalinos.
    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    that’s what I’ve been trying to say ??

    Best wishes,
    Tobias

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

    Thread Starter catalinos

    (@catalinos)

    Thanks! I’ll close the thread! Have a great day!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks! Same to you!

    Best wishes,
    Tobias

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘DataTable is not a function’ is closed to new replies.