The issue is one of scope.
When the init method is called, it is called in the Window scope, as such the value of this
is Window
. You can console.log(this)
in your init method to see.
Couple of things you can do. As you attached App
to the window
object, you can call it directly:
var bookCollection = new App.Collections.BookCollection;
Or you can bind the call of init to the App object:
App.init.call(App);
This will bind the value of this
to the first argument of call
.
You can simplify this further by binding directly when you pass the function doc ready method:
$(document).ready(App.init.bind(App));