442
Views
7
Comments
how to add cdn globally
Question

Greeting,

I want to add jquery cdn in Reactive Web app Globally. 
for a particular screen i am using RequireScript in my client action.
to load the library.
thanks in advance :)


2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Anand

You can set/reference the jQuery library in the Application module as well as in Screen scope by referencing the jQuery library file available in the OutSystemsUI module (using Mange Dependency) as shown below

Hope this helps you!


Regards,

Benjith Sam

UserImage.jpg
anand kumar

Benjith Sam wrote:

Hi Anand

You can set/reference the jQuery library in the Application module as well as in Screen scope by referencing the jQuery library file available in the OutSystemsUI module (using Mange Dependency) as shown below

Hope this helps you!


Regards,

Benjith Sam

 

 thanks for quick response
but i want to add cdn globally not the script file
Regards

2021-03-18 21-03-15
Benjith Sam
 
MVP

anand kumar wrote:

thanks for quick response
but i want to add cdn globally not the script file
Regards

Hi Anand,

I think by defining the below mentioned script

1) either by creating a new script file and referencing the same in the application module

2) In the Screen common Layout, define the block On Initialize event handler action flow within which introduce the JS node with the below script will do the work


var script = document.createElement("script");
script.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js";
script.async = true;
script.defer = true;


document.getElementsByTagName("body")[0].appendChild(script);

Hope this helps you!


Regards, 

Benjith Sam

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Benjith Sam wrote:

anand kumar wrote:

thanks for quick response
but i want to add cdn globally not the script file
Regards

Hi Anand,

I think by defining the below mentioned script

1) either by creating a new script file and referencing the same in the application module

2) In the Screen common Layout, define the block On Initialize event handler action flow within which introduce the JS node with the below script will do the work


var script = document.createElement("script");
script.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js";
script.async = true;
script.defer = true;


document.getElementsByTagName("body")[0].appendChild(script);

Hope this helps you!


Regards, 

Benjith Sam

 from: https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/JavaScript/Extend_Your_Mobile_and_Reactive_Apps_Using_JavaScript/Use_JavaScript_Code_from_an_External_Library

 

UserImage.jpg
anand kumar

Benjith Sam wrote:

anand kumar wrote:

thanks for quick response
but i want to add cdn globally not the script file
Regards

Hi Anand,

I think by defining the below mentioned script

1) either by creating a new script file and referencing the same in the application module

2) In the Screen common Layout, define the block On Initialize event handler action flow within which introduce the JS node with the below script will do the work


var script = document.createElement("script");
script.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js";
script.async = true;
script.defer = true;


document.getElementsByTagName("body")[0].appendChild(script);

Hope this helps you!


Regards, 

Benjith Sam

 hey,

I made a custom block in UI Common flow and added the script you gave,
so when i added jquery in client action and   published to use it,  it's giving error $ is not defined

 

2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi anand,

I totally agree with Daniël's comment...

The error which you encountered clearly states that you might have used the jQuery syntax or $ - jQuery selector (within the newly introduced block) before successfully loading the jQuery library from cdn location

hey,

I made a custom block in UI Common flow and added the script you gave,
so when i added jquery in client action and published to use it, it's giving error $ is not defined 

 

Regards,

Benjith Sam

UserImage.jpg
anand kumar

Benjith Sam wrote:

Hi anand,

I totally agree with Daniël's comment...

The error which you encountered clearly states that you might have used the jQuery syntax or $ - jQuery selector (within the newly introduced block) before successfully loading the jQuery library from cdn location

hey,

I made a custom block in UI Common flow and added the script you gave,
so when i added jquery in client action and published to use it, it's giving error $ is not defined 

 

Regards,

Benjith Sam

 

 Is their a way to prevent it??


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.