I have an app that utilizes Backbone.js. Everything was working fine, but recently I added RequireJS to my project, and that of course made everything break, so I'm in the processes of defining my dependencies and making everything work again.
The error I'm getting is Uncaught ReferenceError: JST is not defined.
I have the following CoffeeScript view file. Note the JST line:
define ["app"], (App) ->
Snip.Views.Appointments ||= {}
class Snip.Views.Appointments.IndexView extends Backbone.View
template: JST["backbone/templates/appointments/index"]
initialize: () ->
@options.appointments.bind('reset', @addAll)
addAll: () =>
@options.appointments.each(@addOne)
addOne: (appointment) =>
view = new Snip.Views.Appointments.AppointmentView({model : appointment})
@$("ul").append(view.render().el)
My "app" dependency itself has Backbone and Underscore as dependencies, so I don't think the problem is that Backbone is not present:
define ["underscore", "backbone"], (_, Backbone) ->
window.Snip =
Models: {}
Collections: {}
Routers: {}
Views: {}
When I load the page, I get Uncaught ReferenceError: JST is not defined
.
What do I need to do to get my script to know about JST?
Edit: here are my paths and stuff
require
paths:
jquery: "jquery-1.7.2.min"
underscore: "lodash.min"
appointment: "backbone/models/appointment"
appointmentIndexView: "backbone/views/appointments/index_view"
appointmentsRouter: "backbone/routers/appointments_router"
relational: "backbone-relational"
shim:
"underscore":
exports: "_"
"backbone":
deps: ["underscore", "jquery"]
exports: "Backbone"
"relational":
deps: ["backbone"]
requirejs ["appointmentsRouter"], (AppointmentsRouter) ->
window.router = new Snip.Routers.AppointmentsRouter({appointments: []})
Backbone.history.start()
I am using Backbone Boilerplate which compiles the templates into one file called templates.js. the JST is defined in templates.js. configure the paths with templates.js resolved the issue.