bartverdonck / Sitecore-Forms-Extensions

http://onelittlespark.bartverdonck.be/category/sitecore-forms-extensions/
MIT License
59 stars 37 forks source link

Use of global JS scope #112

Open markgibbons25 opened 3 years ago

markgibbons25 commented 3 years ago

https://github.com/bartverdonck/Sitecore-Forms-Extensions/blob/8b0371ba2eb355575ff681305738626105ac8a0f/src/Feature/FormsExtensions/code/sitecore%20modules/Web/ExperienceForms/scripts/formsextensions.validate.js#L6

Would we be able to namespace the usage of SFE js so that it's not sitting in global scope?

bartverdonck commented 3 years ago

Hi Mark, You are reaching the boundaries of my skills with this one. Can you make a suggestion or help me out? Best Regards

markgibbons25 commented 3 years ago

Hi Bart, Sure , a good reference on options is https://www.freecodecamp.org/news/javascript-modules-a-beginner-s-guide-783f7d7a5fcc/ - Perhaps the simplest way in this case would be to use the anonymous closure with jquery global import.

Example https://github.com/aspnet/jquery-ajax-unobtrusive/blob/master/src/jquery.unobtrusive-ajax.js