When developing custom Power Bi Visuals using Pbiviz, what could be the cause of the error $ is not a function
?
This issue arises when attempting to specify jQuery plugins. It seems like there may be an incorrect order of libraries, although the output file appears to have the correct one.
tsconfig.json:
{
"compilerOptions": {
"allowJs": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "ES5",
"sourceMap": true,
"out": "./.tmp/build/visual.js"
},
"files": [
".api/v1.7.0/PowerBI-visuals.d.ts",
"src/settings.ts",
"src/visual.ts",
"node_modules/@types/jquery/index.d.ts",
"node_modules/@types/datatables.net/index.d.ts",
"node_modules/@types/lodash/index.d.ts",
"node_modules/powerbi-visuals-utils-dataviewutils/lib/index.d.ts"
]
}
pbiviz.json:
"externalJS": [
"node_modules/powerbi-visuals-utils-dataviewutils/lib/index.js",
"node_modules/jquery/dist/jquery.js",
"node_modules/datatables.net/js/jquery.dataTables.js",
"node_modules/lodash/lodash.min.js"
],
package.json:
"dependencies": {
"@types/datatables.net": "^1.10.1",
"@types/jquery": "^2.0.48",
"@types/lodash": "^4.14.50",
"datatables.net": "^1.10.15",
"jquery": "^2.1.0",
"lodash": "^4.17.4",
"powerbi-visuals-utils-dataviewutils": "1.2.0"
},
Error Message:
Uncaught TypeError: $ is not a function
at <anonymous>:14820:21
at <anonymous>:10387:3
at Window.<anonymous> (<anonymous>:10390:1)
at <anonymous>:25969:20
at Object.r [as injectJsCode] (visualhostcore.min.js:2)
at i.loadWithoutResourcePackage (visualsandbox.min.js:1)
at i.executeMessage (visualsandbox.min.js:1)
at i.onMessageReceived (visualsandbox.min.js:1)
at visualsandbox.min.js:1
at e.invokeHandler (visualhostcore.min.js:2)