I have a requirement that there is a 2 Clientlibs:
1)clientlibA ->clientlibA.js
2)clientlibB ->clientlibB.js
clientlibA.js
(function ($, $document, gAuthor) {
"use strict";
var sampleText="sample-text-1";
})($, $(document), Granite.author);
How can i access sampleText variable in clientlibB.js
Thanks in advance!!
Solved! Go to Solution.
Views
Replies
Total Likes
you can use jQuery Extension Functions, which works as global functions for a request.
@vineel_k If both the clientlibs are invoked within the scope of same page then you can use JS window object to set the value and retrieve at another place (in another clientlib)
window.sampleText="sample-text.-1"
You've to make sure about the execution order i.e. clientlib A logic should execute before clientlib B else property value is going to be undefined.
hi @Himanshu_Singhal clientlibA is presented in one dialog and clientlibB presented in another dialog
i tried above window object getting undefined in console
is there any way to access.
You can target the Javascript global scope. https://www.w3schools.com/js/js_scope.asp
Hi @BrianKasingli i tried with global variables it is working in same dialog when i come back to another dialog in same page is is getting undefined but i need to access it in another dialog in same page
you can use jQuery Extension Functions, which works as global functions for a request.
Views
Likes
Replies