Backbone fetch() throws an Uncaught TypeError: Cannot read property 'ajax' of undefined

backbone.js, coffeescript, fetch, typeerror, undefined

Solution

UPDATE: Solved this on my own. Rookie mistake, not loading dependancies first. I realized that I had goofed and loaded Backbone before jQuery instead of after jQuery. The ajax method was an undefined property because jQuery didn't exist at that point in my code.

A lot of times the simple solution is the correct one. Thank you everyone who jumped in to help out!

Problem

I am integrating BackBone on a new project. While I am somewhat familiar with BackBone, this will be my first attempt at creating a new project with it. I setup a model and view, but am getting a console error that doesn't return any helfpul results on StackOverflow or Google. I'm hoping someone here can spot where I've gone wrong. Here's the error, which occurs when I call `thing.fetch()` ``` Uncaught TypeError: Cannot read property 'ajax' of undefined ``` And here's my CoffeeScript code: ``` Thing = Backbone.Model.extend name: 'thing' url: -> "/things/#{@id}" ThingView = Backbone.Model.extend el: "#thing" render: -> console.log 'render', @$el thing = new Thing(id: 1) thing.fetch() thingView = new ThingView()(model: Thing) thingView.render() ```

Original source