JavaScript namespacing - observing good practice | HCL Digital Experience
The client side context of Web programming requires good namespacing.
About this task
htmlEditor.js:
if ( typeof( HTMLEditorController ) == "undefined" ) {
var HTMLEditorController = function( namespace ) {
this._namespace = namespace;
this.getSaveForm = function () {
return document.forms[ namespace + "saveForm" ]
}
}
}
htmlEditor.jsp:
var <%=namespace%>htmlController = new HTMLEditorController( "<%=namespace%>" );