ajax.reload() can not get to work - crazy

ajax.reload() can not get to work - crazy

ionluchianionluchian Posts: 1Questions: 1Answers: 0
edited April 2017 in Free community support

i can not get to work my ajax.reload()

my code is below what i do wrong?

DataTablesDraw = (selector, order, pages, file, sort, column, template, data_set) ->
$(selector).DataTable
  'pageLength': pages
  'ordering': sort
  'destroy' : true,
  'paging': true
  'responsive': true
  'searching': false
  'info': false
  'lengthChange': true
  'autoWidth': false
  'select': true
  'dom': 'Bfrtip',

  'buttons': [
          {
            'extend': 'excelHtml5',
            'title': file + new Date()
          },
          'copyHtml5'
      ],
  'order': [ [ column, 'desc' ] ],
  'language': {
        buttons: {
            copyTitle: i18n[lang]['id[9]'],
            copySuccess: {
                _: i18n[lang]['id[10]'] + ' %d ' + i18n[lang]['id[11]'],
                1: i18n[lang]['id[12]']
            }
        }
    }
  'ajax': '/settings/ranges/ranges.txt',
  "dataSrc": "data",
  'drawCallback': (settings) ->

    $('.dataTables_paginate > span').remove()
    excel = $('#DataTables_Table_' + order + '_wrapper .buttons-excel').detach()
    copy = $('#DataTables_Table_' + order + '_wrapper .buttons-copy').detach()

    if not $('#DataTables_Table_' + order + '_wrapper thead.tfoot').length
      $(this).append '<thead class="tfoot">' +
            '<tr>' +
                '<th colspan="10">' +
                    '<div class="export">' +
                        '<div class="buttons"></div>' +
                    '</div>' +
                    '<div class="paginator"></div>' +
                '</th>' +
            '</tr>' +
         '</thead>'

    paginator = $('#DataTables_Table_' + order + '_paginate').detach()
    $('#DataTables_Table_' + order + '_wrapper thead .paginator').append paginator
    $('#DataTables_Table_' + order + '_wrapper thead .export .buttons').append excel, copy

    if @fnPagingInfo().iTotalPages <= 1
      $('#DataTables_Table_' + order + '_paginate').hide()
      $('#DataTables_Table_' + order + '_info').hide()
    else
      $('#DataTables_Table_' + order + '_paginate').show()
      $('#DataTables_Table_' + order + '_info').show()

    return

  'columns': template
return


calling
table= DataTablesDraw '.__ranges__', 0, 25, 'Current Ranges ', true, 5, CurrentRangesTemplate, ranges #selector, order, pages, file name, sorting
table.ajax.reload()

data
{"data": [{"status": "1", "environment": "demo", "currency": "EUR", "range_to": 42342, "date_update": 1491814286, "server": "server", "date_create": 1491814286, "platform": "platform", "range_from": 432423, "user": {"email": "test@test.com"}]}

and in the console getting this error

Uncaught TypeError: Cannot read property 'ajax' of undefined

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 63,217Questions: 1Answers: 10,415 Site admin

    Can you show me the above complied into Javascript please?

    Allan

This discussion has been closed.