Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8395635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:21:00+00:00 2026-06-09T20:21:00+00:00

I just started this HTML5 project where we decided to make it a single

  • 0

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.

The architecture looks like this:

dashboard.html (master file)
moduleA.html
moduleA.js
moduleB.html
moduleB.js
moduleC.html
moduleC.js

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.

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:

<script>

moduleA

</script>

or this if we want to access a specific property of this member.

<script>

moduleA.someMethod();

</script>

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.

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.

I looked through the other questions but I didn’t see anyone with the same problem.

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.

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

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:21:02+00:00Added an answer on June 9, 2026 at 8:21 pm

    I could argue about AngularJS with you. It is exactly what you need

    dashboard.html is layout with some directives attached, but power lies in AngularJs if you use ng-view directive

    here is example:

    dashboard.js

    var app = angular.module("modularApp",[]);
    app.config(['$routeProvider', "$locationProvider", function routes($routeProvider, $locationProvider) {
        $routeProvider.when('/dashboard', {
            controller:'HomeCtrl',
            templateUrl:'templates/home.html'
        });    
        $routeProvider.when('/moduleA', {
            controller:'ModuleACtrl',
            templateUrl:'templates/moduleA.html'
        });
        $routeProvider.when('/moduleB', {
            controller:'ModuleBCtrl',
            templateUrl:'templates/moduleB.html'
        });
        $routeProvider.otherwise({redirectTo: "/dashboard"});
    }]);
    

    templates/dashboard.html

    <html ng-app="modularApp">
    <head>
      <!--.... include angular minified js file and what else you need...-->
      <script type="text/javascript" src="dashboard.js"></script>
      <script type="text/javascript" src="moduleACtrl.js"></script>
      <script type="text/javascript" src="moduleBCtrl.js"></script>
    </head>
    <body>
      <a ng-href="#/moduleA">Open Module A View</a>
      <a ng-href="#/moduleB">Open Module B View</a>
      <!-- Add widgets header menus .... -->
      <ng-view></ng-view>
    </body>
    </html>
    

    moduleACtrl.js

    var app=angular.module("modularApp");
    app.controller("ModuleACtrl",function($scope){
      $scope.scopeValue="Hellow from view";
    });
    

    moduleBCtrl.js

    var app=angular.module("modularApp");
    app.controller("ModuleBCtrl",function($scope){
      $scope.scopeValue="Hellow from another view";
    });
    

    templates/moduleA.html

    <div>{{scopeValue}} in module A</div>
    

    templates/moduleB.html

    <div>{{scopeValue}} in module B</div>
    

    You can do more complex things with angular then just this. All depends on your needs. Do you have any special requirements 🙂


    Also, you could create your own directive, like ng-view and use your own $route service and $routeProvider so you can add css and javascript you want to dynamically load when some rute match url.

    so instead of above routing table, you could have

    app.config(['$myRouteProvider', "$locationProvider", function routes($routeProvider, $locationProvider) {
            $routeProvider.when('/dashboard', {
                javascript:'javascript/dashboard.js',
                templateUrl:'templates/dashboard.html',
                cssfile: 'css/dashboard.css'
            });    
            $routeProvider.when('/moduleA', {
                javascript:'javascript/moduleA.js',
                templateUrl:'templates/moduleA.html',
                cssfile: 'css/moduleA.css'
            });
            $routeProvider.when('/moduleB', {
                javascript:'javascript/moduleB.js',
                templateUrl:'templates/moduleB.html',
                cssfile: 'css/moduleB.css'
    
            });
            $routeProvider.otherwise({redirectTo: "/dashboard"});
        }]);
    

    But that is, pardon on my French, stup. There are couple libs I tried in ruby on rails to acheive similar, but backend is rendering content, or just part of content. But I’m not sure which backend you are using and are you interested to switch to rails anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started considering using the HTML 5 api for a Rails/JQuery project,
I've just started using Jquery UI for a new project. I've uploaded the example
I just started in this SQLAlchemy ORM and I was wondering, if after calling
I just started getting this error today, seemingly out of nowhere. Any one see
I've just started with this section of the tutorial. I only have a basic
This just started happening three weeks or so ago. The content of my website
I just started learning Flex this week, and I cannot get an image path
I just started using @font-face This is on top of my css @font-face {
I just started learning C but I don't understand this part of the code.
This build warning just started showing up. I'm building for 3.1.3. Not sure what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.