javascript - Uncaught TypeError: $ is not a function ( requirejs define method) -
i'm having difficulty including datatables plugin https://datatables.net/manual/installation#local-installation in widget.
in jquery.datatables.js there function supposed assign jquery variable $
if ( typeof define === 'function' && define.amd ) { // amd alert('amd'); define( ['assets/js/jquery/jquery-3.2.1'], function ( $ ) { alert('common1'); alert( $ ); return factory( $, window, document ); } ); however, alert ( $ ) shows $ undefined it's supposed function constructor jquery
in case, in subsequent function of jquery.datatables.min there main function takes in:
(function( $, window, document, undefined ) and in function, on first use of $ uncaught typeerror: $ not function
why getting error , due define of jquery causing issue?
even if do:
var $ = require define( ['assets/js/jquery/jquery-3.2.1']) right before main function, still don't $.fn.datatables function in global?
i know question kind of mess hoping give me pointers of start looking on how resolve issue.
try load jquery directly cdn in header , not try load using amd.
make sure jquery first library loaded in header, example:
<head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!-- other scripts below --> </head>
Comments
Post a Comment