I need to draw editable JSON trees, to use that I've chosen this library - https://github.com/josdejong/jsoneditor; the idea is to draw trees inside a Terrasoft.ViewItemType.CONTAINER.
My understanding was that to import this(or any other) library I need to create a module and put a define() {} inside it, and inside that goes the library code(jsoneditor.js contents in my case), so I ended up doing that:
define("UsrJsonEditor", [], function () { // jsoneditor.js contents }
After that I'm importing that module to my page and trying to check if it works by doing this:
define("UsrCardOrders1Page", ["ProcessModuleUtilities", "UsrJsonEditor"], function(ProcessModuleUtilities, UsrJsonEditor) { return { ... methods: { initializeJsonEditor: function() { window.console.log("UsrJsonEditor: " + UsrJsonEditor); window.console.log("UsrJsonEditor.JSONEditor: " + UsrJsonEditor.JSONEditor); }, ... } { });
The initializeJsonEditor() function is called when the container is rendered.
This results in the following error:
Uncaught Error: Mismatched anonymous define() module: function () { return /******/ (function () { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 6545: /***/ (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ t: function () { return /* binding */ ContextMenu; } /* harmony export */ }); /* harmony import */ var _createAbsoluteAnchor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1925); /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6237); /* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3057); function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.construc…
I don't have enough experience with JS, but as I understand it the problem is that I've ended up with with the library's define() inside my own define(). Could someone tell if my approach is generally correct and what is that I'm doing wrong here?
Like
You can load it via the CDN using requirejs. See my response on this thread: https://community.creatio.com/questions/how-include-external-js-file-creatio
Ryan
You can load it via the CDN using requirejs. See my response on this thread: https://community.creatio.com/questions/how-include-external-js-file-creatio
Ryan