Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : CanJS Large Scale Application

$
0
0
I create can.Observe when application starts. This observe is then passed to each can.Control (widget) which I create. Each widget can listen to observe changes and it can also set new values.
On http://skypicker.com/ I currently have 7 can.Control (search form, map, results, departure, return, map zoom and common). If I omit i.e. map control, the application can still work.
I don't like to use can.route because of !# in url and instead of that I use html5 history api. When application starts I can parse the url and initialize that can.Observe with initial values.

  1. this.filter = new can.Observe({
  2. from: { // start destination
  3. id: null, // id of currently selected destination
  4. type: null // type of current destination (city, airport, country)
  5. },
  6. to: { // end destination
  7. id: null, // id of currently selected destination
  8. type: null // type of current destination (city, airport, country)
  9. },
  10. date: { ... }
  11. });

  12. // create module which handles form filter
  13. Skypicker.Form = new Form('#form', {
  14. filter: filter
  15. });

  16. // create module which handles map
  17. Skypicker.Map = new Map('#map_canvas', {
  18. filter: filter,
  19. ...
  20. });

Viewing all articles
Browse latest Browse all 3491

Trending Articles