Results 1 to 3 of 3

Thread: Sencha Touch MVC and Namespaces

  1. #1

    Default Sencha Touch MVC and Namespaces


    I'm starting a rather complex web application using Sencha Touch and having a hard time understanding how namespaces work across multiple class files. Let me start by briefly outlining the application tree :

    I purposely left out the lib and resources folders as they aren't relevant to the current problem. Now inside my app.js there is a simple launch function which instantiates the Viewport. Inside the Viewport I can use the app.views namespace freely, I can add classes to that namespace etc. I can also use the app.views namespace anywhere in my other files inside the "medecins" folder. All this is good and working great.

    Now my problem is that I want classes inside the "medecins" folder to be under the app.views.medecins namespace (not simply app.views). How do I do that ? And how do I reference them in other files ? Is there something like a "use" statement ? I tried all kinds of things but just came to the conclusion that I'm lacking some knowledge regarding namespaces in Sencha Touch.

    Any help would be appreciated. Thanks

  2. #2


    Ok, so it seems I've found out the missing piece of information. I only needed to declare the app.views.medecins namespace using Ext.ns before using it. Now I have another little question : where is the best place to add new namespaces when you have lots of them ? Make a dedicated JS where you only declare namespaces ? Add them in app.js ? Or just add each one in the first JS that uses it ?


    PS : Feel free to add any information on namespaces if you think it could help.

  3. #3
    Sencha User
    Join Date
    Jul 2010


    I put my extra name spaces in app.js, but I don't have many to add. Adding a namespace to the first js file that uses it seems kind of unsafe. I think you can add the same namespace to multiple files without harm, so just add the appropriate namespace to every file if you want to take that route.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts