How to create a controller js | Community
Skip to main content
Level 2
October 16, 2015
Solved

How to create a controller js

  • October 16, 2015
  • 1 reply
  • 1096 views

Hi Guys ,

There are some Js files in libs , such as the preferences.js (/libs/cq/security/widgets/source/widgets/security/Preferences.js).

I copied the same file to my apps folder and when i instantiate some variables (My_Prop = "new prop") , it can be accessed from anywhere (any other JS file).

I dont want to disturb the preferences.js . I want to create my own js similar to this so that when i declare some properties , it shall be available anywhere and accessed from every other js file.

 

Thanks in advance

Harish

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Ojjis

Hi Harish,
Either, you can just create these JS files and include them to your ClientLib. Then make sure that they have the correct categories and dependencies so that they will be included at the right point. After that they can be used from your other files in your code.

If that is not enough and you really need them to be included at an earlier stage, you can create those files and make sure that a js.txt file will include your script files somewhere else. There are loads of these and you have to check when and where those files are included so you wont run into any problems.

Good Luck
/Johan

1 reply

Ojjis
OjjisAccepted solution
Level 7
October 16, 2015

Hi Harish,
Either, you can just create these JS files and include them to your ClientLib. Then make sure that they have the correct categories and dependencies so that they will be included at the right point. After that they can be used from your other files in your code.

If that is not enough and you really need them to be included at an earlier stage, you can create those files and make sure that a js.txt file will include your script files somewhere else. There are loads of these and you have to check when and where those files are included so you wont run into any problems.

Good Luck
/Johan