This is driving me crazy right now. I cannot get a simple router to work…
jQuery ->
class MyRouter extends Backbone.Router
routes:
"" :"index"
"/list" :"showList"
"/item/:id" :"showItem"
index: =>
alert "index"
showList: =>
alert "get the lists"
showItem: (id)=>
alert "the item #{id}"
@app = window ? {}
@app = window.app ? {}
@app.myRouter = MyRouter
Backbone.history.start()
I always get this error:
index.js:50Uncaught TypeError: Cannot call method 'start' of undefined
and I saw this: Cannot call 'start' of undefined when starting backbone.js history.
but it did not help =(…
I am sure this is an easy one but I am some sort of stuck here …
please help…
You didn’t create an instance of a Backbone.Router, so
Backbone.history.start()will fail.The link you posted tells you exactly what the problem is: