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

Re : how to manage route.pushstate detection on init?

$
0
0
Maybe if I post some code, it'll make more sense to you guys?

/app/init.js:
  1. require.config({paths:
  2. {
  3. can: "libs/canjs-2.0.3/amd/can/",
  4. jquery: "libs/jquery-2.0.3"
  5. }});

  6. require(["app","can/route/pushstate"], function(app)
  7. {
  8. can.route.bindings.pushstate.root = "/app/";
  9. new app( $(".app") );
  10. });
/app/app.js:
  1. define(["can/control"], function()
  2. {
  3. return can.Control.extend(
  4. {
  5. init: function(element, options)
  6. {
  7. element.html( can.view("templates/app.mustache", {}) );
  8. can.route(":section");
  9. can.route.ready();
  10. can.route.attr("section", "");      // test root (fails)
  11. },
  12. ":section route": function(data)
  13. {
  14. console.log(":section route");
  15. // instantiate other components here
  16. },
  17. "route": function(data)
  18. {
  19. console.log("route");
  20.                         // instantiate "homepage" component here
  21. }
  22. });
  23. });

Viewing all articles
Browse latest Browse all 3491

Trending Articles