Uncaught TypeError: Cannot set property '$' of undefined - Page 2

Uncaught TypeError: Cannot set property '$' of undefined

2»

Answers

  • allanallan Posts: 61,669Questions: 1Answers: 10,096 Site admin

    Could you show me the page that has that please? As you say, that is wrong and it needs to be fixed.

    Thanks,
    Allan

  • david10singdavid10sing Posts: 1Questions: 0Answers: 0

    This has been opened since 2017 and still no answer for this. I'm getting same error using the NPM package and requiring....

  • pauloh159pauloh159 Posts: 2Questions: 0Answers: 0

    I managed to resolve this error in this way. If it is useful for someone.

    import * as $ from 'jquery'
    import dt from 'datatables.net-dt'
    $.fn.DataTable = dt
    
    $('#example').DataTable()
    
  • xlpxlp Posts: 1Questions: 0Answers: 0
        global.$ = global.jQuery = require('jquery');
    
    
        var dt      = require( 'datatables.net' );
    

    This is my solution

  • bremgbremg Posts: 4Questions: 0Answers: 0

    thanks @xlp, this is the only solution that worked.

    The worst documentation ever did it again. Everything datatables related is always a huge fight, especially since the documentation is always incorrect.

    For a totally clean application this worked:
    global.$ = global.jQuery = require('jquery');
    var dt = require( 'datatables.net' );

  • tangerinetangerine Posts: 3,348Questions: 36Answers: 394

    the documentation is always incorrect.

    Please provide examples of incorrect documentation.

This discussion has been closed.