title: Trouble with Creating Backbone Models & Collections
body: <p>I'm really, <em>really</em> trying to learn Backbone and it's quite a lot for me to wrap my head around (coming from Rails). So I'm trying to code a simple app that just fetches a collection from a Sinatra backend. Right now, the route <code>/schools</code> returns a JSON object that looks like <code>["One School", "Two School"]</code>. Pretty simple. Unfortunately, the following always returns <code>ReferenceError</code> for me:</p>
  
  <p><strong>School model</strong></p>
  
  <pre><code>(function() {
     window.school = Backbone.Model.extend({});
  }).call(this);
  </code></pre>
  
  <p><strong>School collection</strong></p>
  
  <pre><code>(function() {
    window.schools = Backbone.Collection.extend({
      url: '/schools',
      model: window.school
    });
  }).call(this);
  </code></pre>
  
  <p><strong>Console</strong></p>
  
  <pre><code>var f = new window.school({name: "temp"});
  </code></pre>
  
  <p><em>undefined</em></p>
  
  <pre><code>f.id();
  </code></pre>
  
  <p><em>ReferenceErrror</em></p>
  
  <p>So simple interactions like this won't work. Also, calling <code>window.schools.fetch()</code> results in a UndefinedObject error. Don't know where I went wrong exactly, but nothing seems to be working. Any help would be awesome!</p>
  
  <p><em>Edit:</em> The collection &amp; model are written in a closure because its compiled from Coffeescript.</p>