# Canjs route running

**URL:** <https://forums.bitovi.com/t/canjs-route-running/56>\
**Category:** Uncategorized\
**Created:** [November 19, 2015, 4:28am UTC](https://forums.bitovi.com/t/canjs-route-running/56 "2015-11-19T04:28:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![marvengong](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@marvengong](https://forums.bitovi.com/u/marvengong)\
**Post date:** [November 19, 2015, 4:28am UTC](https://forums.bitovi.com/t/canjs-route-running/56/1 "2015-11-19T04:28:27Z")

</div>

I have made a demo of can.route,It can run when I open the page by this way :“file:///D:/work/bowerDemo/routeDemo.html#!findStudent/2/8” but when i open the page like this “[http://test.bower-canjs.com/route\_demo01.html#!student/3/5](http://test.bower-canjs.com/route_demo01.html#!student/3/5)”,it does not work.How can I resolve this problem .

---

<div class="post-metadata">

**Author:** ![justinbmeyer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/justinbmeyer/32/179_2.png) [@justinbmeyer](https://forums.bitovi.com/u/justinbmeyer)\
**Post date:** [November 19, 2015, 5:26am UTC](https://forums.bitovi.com/t/canjs-route-running/56/2 "2015-11-19T05:26:33Z")

</div>

Can you create a JSBin or provide a sample of your code?

---

<div class="post-metadata">

**Author:** ![marvengong](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@marvengong](https://forums.bitovi.com/u/marvengong)\
**Post date:** [November 19, 2015, 7:32am UTC](https://forums.bitovi.com/t/canjs-route-running/56/3 "2015-11-19T07:32:05Z")

</div>

```
window.location.hash="#!student/1/5";
can.route("#!student/:pageNo/:pageCount",{pageNo:1,pageCount:5});
can.route.attr({
	"action":"student"
});
var student=can.Control.extend({
	init:function(){
		
	},
	"student/:pageNo/:pageCount route":function(data){
		console.log("pageCount="+data.pageCount);
		console.log("pageNo="+data.pageNo);
	},
	"action route":function(data){
		console.log(data);
	},
	"{can.route} change":function(ev,attr,how,newAttr,oldAttr){
		console.log(ev,attr,how,newAttr,oldAttr);
	}
});
new student("body");
/*can.route.bind("change",function(ev,attr,how,newAttr,oldAttr){
	console.log(ev,attr,how,newAttr,oldAttr);
})*/
can.route.ready();
```

---

<div class="post-metadata">

**Author:** ![justinbmeyer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/justinbmeyer/32/179_2.png) [@justinbmeyer](https://forums.bitovi.com/u/justinbmeyer)\
**Post date:** [November 19, 2015, 3:26pm UTC](https://forums.bitovi.com/t/canjs-route-running/56/4 "2015-11-19T15:26:30Z")

</div>

In general, this code is outdated. It’s best to avoid Controls (except when making pure-DOM widgets), and it’s even better to avoid can/control/routes like `"student/:pageNo/:pageCount route"`.

I made a JSbin that shows what you have working: [http://justinbmeyer.jsbin.com/zobawa/edit?js,console,output](http://justinbmeyer.jsbin.com/zobawa/edit?js,console,output)

I hade to change:

`new student("body");`

to `new student(document.body);`

Are you new to CanJS? If yes, I’d encourage you to use Components instead of Controls. Checkout DoneJS’s getting started guide for an intro that shows CanJS’s routing.

---

<div class="post-metadata">

**Author:** ![marvengong](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@marvengong](https://forums.bitovi.com/u/marvengong)\
**Post date:** [November 20, 2015, 3:03pm UTC](https://forums.bitovi.com/t/canjs-route-running/56/5 "2015-11-20T15:03:44Z")

</div>

Excuse me.May I get some help from you that about ‘canjs’ more information?Or can you give me some simple demo of it?Thank you

---

<div class="post-metadata">

**Author:** ![cherif\_b](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/cherif_b/32/31_2.png) [@cherif\_b](https://forums.bitovi.com/u/cherif_b)\
**Post date:** [November 26, 2015, 3:12pm UTC](https://forums.bitovi.com/t/canjs-route-running/56/6 "2015-11-26T15:12:52Z")

</div>

@marvengong DoneJs helps you start with canjs just follow the getting started guide
