1

When creating simple projects we directly specify models and controllers in the same file and then write. My app.js looks like this:

var Library = can.Model({});   
var Control = can.Control({.....});    
var control = new Control('#main');

and single html file for this

For complex applications i will have different folders for controllers, models and views. My first question is

1 How will the invocation will take place when I place the controllers in different folder and the Modules in different folders. Can some one help me with a template of a base file which will invoke all the controllers.

1.If I have a simple html file for a specific controller instead of an ejs will it work?

I know it might sound stupid to some extend but I am confused.

Regards,

ramblinjan
  • 6,288
  • 3
  • 26
  • 38
Shraddha Shravagi
  • 1,036
  • 1
  • 9
  • 22

3 Answers3

1

Have a look at the CanJS + RequireJS TodoMVC example. This should demonstrate everything you need to get started with RequireJS using the AMD module version of CanJS.

And of course you can instantiate your control in an HTML file without having to use EJS (or Mustache) views.

Daff
  • 41,847
  • 9
  • 99
  • 113
1

You can either use a tool like require.js, your code will look something like this:

define(['control' ], function(Control){ 
    var control = new Control('#id');       
});

Or use namespaces:

// user_control.js
APP.controllers = APP.controllers || {};
APP.controllers.UserControl = can.Control({...

// other file
var control = APP.controllers.UserControl('#id');
Sebastian
  • 2,179
  • 15
  • 19
0

To instantiate an html instead of ejs we can use

this.view({
            url: 'views/demos/accordion.html'
        });

Might be useful for some one else.

Shraddha Shravagi
  • 1,036
  • 1
  • 9
  • 22