0

I wanna implement the Name Space concept in my JavaScript code, I am using ExtJS, but I don't know where to start, anyone could help me? The site example is very short.

Danilo M.
  • 1,422
  • 5
  • 17
  • 31

2 Answers2

1

Here is a good sample How do I declare a namespace in JavaScript?

and here is too https://developer.mozilla.org/en-US/docs/XUL/School_tutorial/JavaScript_Object_Management

Community
  • 1
  • 1
Boris Gappov
  • 2,483
  • 18
  • 23
1

Actually in ExtJS4 the App name is your name space. So for example if you define your app this way:

Ext.application({
    name: 'MyApp',
    appFolder: 'app', 
    autoCreateViewport: true,
    controllers: [
        'MyController'
        ],
    launch: function() {
        console.log('hello');

        // This is fired as soon as the page is ready
    }
});​

then all of your components you define need to be namespaced with MyApp. So a controller becomes MyApp.controller.MyController and a view becomes MyApp.view.InboxGrid

dbrin
  • 15,525
  • 4
  • 56
  • 83
  • So Namespace was not what I expected, I have a controller with many lines of code, I just wanted to better organize this functionality by separating code, I thought that this was possible using namespace. For example, I have code that saves a student and a code that saves a teacher within the same controller, I wanted to better organize in different files. – Danilo M. Nov 27 '12 at 16:32
  • You can have more than one controller if thats what you are after. – dbrin Nov 27 '12 at 19:40
  • I want to have 2 controllers, but I would to call the functions in just one controller, do you understand what I want to do ? - 1 Controller to student functions - 1 controller to teacher functions and 1 controller to manage this functions. – Danilo M. Nov 28 '12 at 10:17
  • I am afraid I am not following your line of thinking. There are Architecture guides to MVC on the Sencha site - perhaps it would help following their suggested way of structuring your app. – dbrin Nov 28 '12 at 18:26