Javascript single page architecture with module autonomy
<p>I just started this HTML5 project where we decided to make it a single page architecture by leveraging jQuery $.load() method. Unfortunately, as soon as the JS started to grow, we quickly started running into issues where the modules loaded into the master dashboard have no knowledge of their parent.</p>

<p>The architecture looks like this:</p>

<p>dashboard.html (master file)<br>
moduleA.html<br>
moduleA.js<br>
moduleB.html<br>
moduleB.js<br>
moduleC.html<br>
moduleC.js</p>

<p>Since we decided to also keep the JS as separate files, we are having to load all JS files through dashboard.html in order to invoke them individually when modulex is loaded.</p>

<p>So when loading moduleA.html into the dashboard we have to call its corresponding JS. To do this we simply wrote the JS using a Module Pattern so we can easily invoke it by doing a function call, like:</p>

<pre>
&lt;script&gt;

moduleA

&lt;/script&gt;
</pre>

<p>or this if we want to access a specific property of this member.</p>

<pre>
&lt;script&gt;

moduleA.someMethod();

&lt;/script&gt;
</pre>

<p>Now, I know there are is gotta be a nicer way of doing this, right? I hate having to have script tags in the HTML modules in order to load its corresponding JS file.</p>

<p>Another limitation of this is the fact that we no longer can work on modules individually, since the scripts and CSS invocation happens on the parent (dashboard.html) so certainly when moduleA.html is loaded directly, it is pure HTML with no script or CSS.</p>

<p>I looked through the other questions but I didn't see anyone with the same problem.</p>

<p>I looked at AngularJS, EmberJS, KO.JS and BoilerPlateJS but none of them addresses what we are trying to accomplish. The only one that has a similar single page concept is jQuery Mobile but I don't know if you can switch from jQuery to jQuery Mobile and everything remains working.</p>

<p>Has anyone face this issue yet? Is there a solution or would I have to go with a custom solution.</p>

<p>Thanks!</p>
