I have tried Spinejs library for a few days, I have the document on Spinejs.com but till now, I still don't know how exactly Spine routing work. From the document, I know how to create a new route and add them to Spine routing. But how it work? I tried to create an example with 2 controller Task and TaskList extends from Spine.Controller, I also did add 2 routing controllers: "#/task" and "#/tasklist":
Spine.route.add("#/task");
Spine.route.add("#/tasklist");
Spine.route.setup();
in Task and TaskList controller, I simply alert an message in their constructor.
But when I browse: "http://hellospine.html/#task" -> nothing happen then "http://hellospine.html/#tasklist" -> nothing happen I thought that, the route values in url "#task" and "#tasklist" let spine call constructor of appropriate controller, but it's not working.
Do you have any idea ? Should I config anymore to make it run appropriate controller ? I also wanna know work flow of spine routing, please help me, thanks a lot!
3 things:
Spine.Route.add
is meant to be used out of controllers. #
. so:
Spine.Route.add('/hi', function () {
alert('Hey you!');
});
Spine.Route.setup()
demo here
But please refer to http://spinejs.com/docs/routing
Cheers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.