I'm trying to create a JavaScript component that is reusable in any web application (pure js only allowed). And more than one instance can exist at a time on a web page.
Client HTML
<head runat="server">
<title></title>
<link href="StyleSheet.css" rel="stylesheet" />
<script src="MyComponent.js"></script>
<script type="text/javascript">
window.onload = function () {
MyComponent.init();
};
</script>
</head>
MyComponent.js
var MyComponent = {};
(function () {
var ns = MyComponent;
ns.init = function () { alert('test'); }
}());
How would I instantiate the component above?
newing?