How to send parameter to language url

How to send parameter to language url

inajafinajaf Posts: 13Questions: 8Answers: 0
edited November 2021 in DataTables 1.8

Guys, how to send parameter to** language: { url: ** . url is not visible in language

 var url = 'Not set';

    var emp = $('#countable')
        .on('init.dt', function () {

            let language = document.documentElement.lang;

            if (language === 'az') {
                url = '/plugins/datatables/i18n/az_AZ.json'
            } else if (language === 'ru') {
                url = '/plugins/datatables/i18n/ru_RU.json'
            }
        })

        .DataTable({
            language: {
                url: url,
                paginate: {
                    next: '»',
                    previous: '«'
                },
            },

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 14,635Questions: 25Answers: 3,475
    Answer ✓

    The init event fires after Datatables initialization not before. Move lines 6-12 outside the init function and execute those statements before initializing Datatables. Place them on line 2 for example.

    Kevin

Sign In or Register to comment.