From c9e8afbcad744f603a4d9fed988a1f200d7585a4 Mon Sep 17 00:00:00 2001 From: Dmitry Kurmanov Date: Thu, 22 Aug 2024 14:40:49 +0400 Subject: [PATCH] work for the https://github.com/surveyjs/survey-library/issues/8717 (#8724) --- src/entries/js-ui.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/entries/js-ui.ts b/src/entries/js-ui.ts index ceb4392e67..90be19dec1 100644 --- a/src/entries/js-ui.ts +++ b/src/entries/js-ui.ts @@ -1,6 +1,5 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; -import jQuery from "jquery"; export { useState, useId, @@ -45,8 +44,6 @@ export { useState, SuspenseList, lazy, } from "preact/compat"; -// import jQuery from "jquery"; - // eslint-disable-next-line surveyjs/no-imports-from-entries import { Survey, PopupSurvey } from "../../packages/survey-react-ui/entries/react-ui-model"; @@ -68,8 +65,20 @@ function doPopupSurvey(props: any): void { }); } -if (typeof jQuery !== "undefined") { - jQuery["fn"].extend({ +let jQueryInst = window["jQuery"] || window["$"]; + +if (typeof jQueryInst !== "undefined") { + initJquery(jQueryInst); +} else { + try { + jQueryInst = require("jquery"); + initJquery(jQueryInst); + } catch (ex) { + } +} + +function initJquery(instance: any) { + instance["fn"].extend({ Survey: function (props: any) { return this.each(function () { renderSurvey(props.model, this, props);