Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I get Cannot call 'start' of undefined when calling...

    Backbone.history.start()

When running some checks Backbone returns the object but Backbone.history returns undefined.

What could be the cause of this?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
221 views
Welcome To Ask or Share your Answers For Others

1 Answer

Do you have any routes on the controller? Backbone only creates the history once at least one route is specified.

More:

TypeError: Cannot call method 'start' of undefined**

Hmm, for some reason Backbone.history is undefined, and so there is no start method on it. It turns out that Backbone.js creates an instance of Backbone.History (upper case ‘H’) called Backbone.history (lower case ‘h’) once a controller has been created that has at least one route specified on it. This makes sense, as history management is only required if there are routes to respond to.

http://tinnedfruit.com/2011/04/26/testing-backbone-apps-with-jasmine-sinon-3.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...