Non-jQuery initialisation not work

Non-jQuery initialisation not work

reimaxreimax Posts: 10Questions: 3Answers: 0

i use this example: https://datatables.net/examples/non_jquery/init.html
i init table:

var datatable = new DataTable(document.querySelector('.table_class'));
...come code.....

open page and "Uncaught ReferenceError: jQuery is not defined"

!function(n) {
    "use strict";
    "function" == typeof define && define.amd ? define(["jquery"], function(t) {
        return n(t, window, document)
    }) : "object" == typeof exports ? module.exports = function(t, e) {
        return t = t || window,
        e = e || ("undefined" != typeof window ? require("jquery") : require("jquery")(t)),
        n(e, t, t.document)
    }
    : window.DataTable = n(jQuery, window, document)

in example page i see, that use https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js
no jquery version?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,118Questions: 1Answers: 2,583

    The example still requires jQuery on the page - have you loaded that library?

    If that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • reimaxreimax Posts: 10Questions: 3Answers: 0

    i not use jquery on my project.
    i download datatable from this page - https://datatables.net/download/
    and not select jquery.

  • colincolin Posts: 15,118Questions: 1Answers: 2,583
    edited January 2022 Answer ✓

    Yep, you need to also include jQuery - as the text on the example states :

    Please note that while this constrctor does not require you to write any jQuery code, DataTables will still use jQuery as a dependency.

    You can either add that dependency in the download page, i.e. this, or just add yourself,

    Colin

  • reimaxreimax Posts: 10Questions: 3Answers: 0

    thanks! i add to packages jquery.

    it is planned to remove jquery as a dependency?

  • kthorngrenkthorngren Posts: 20,147Questions: 26Answers: 4,736

    Here is one of a few threads discussing this. Sounds like the answer is no.

    Kevin

Sign In or Register to comment.