I would suggest creating a namespace variable var App = {};
App.myGrid = ...
This way you can limit the pollution of the global namespace.
EDITOR: Regarding the number of variables - 2 possible solutions:
- You can additionally use the namespace by type (grids, buttons, etc.) or by relations (ClientInfoSection, AddressSection, etc.).
- You encapsulate your methods in objects that are created using the components you have.
ex: do you have
function foo() { myCombo.someMethod(); myGrid.someMethod(); }
becomes:
var Foo = function(combo, grid) { var myCombo = combo;
this way you limit the number of small objects and reveal only what you need (namely, the foo function)
PS: if you need to expose internal components, add them to this inside the constructor function
Liviu T. Aug 01 2018-11-11T00: 00Z
source share