0

I'm currently building a mobile web application with jQM, Highcharts and HTML5.

To maintain the JavaScript code, I decided to apply Revealing module pattern to the code.

Here is my code.

var MobileWebV1 = function () {

    function _buildPanelMenu(pageId, isNormalMenu) {
    }

    function _buildHeaderBar(pageId, isNormalMenu) {
    }

    return {
        buildPanelMenu: _buildPanelMenu,
        buildHeaderBar: _buildHeaderBar
    };
}();

I'm wondering if I can add another hierarchy to categorize methods in the object.

I want to add 'UserInterface' and 'Util.' In that case, I can call the method like this: MobileWebV1.UserInterface.buildPanelMenu('pageHome', false);

I tried to modify my objecy, but I'm still stuck with the current issue.

If you know the answer, then please share your knowledge.

1
  • Show us what you have tried. Yes, you will need to modify your object. Commented Apr 9, 2013 at 16:28

1 Answer 1

1

Just nest the object literals:

return {
    Util: {
        …
    },
    UserInterface: {
        buildPanelMenu: _buildPanelMenu,
        buildHeaderBar: _buildHeaderBar
    }
};
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.