0

CoffeeScriptには次のバックボーンルーター定義があります。

// appointments_router.js.coffee
define ["app", "appointment"], (App) ->
  class Snip.Routers.AppointmentsRouter extends Backbone.Router
    initialize: (options) ->
      @appointments = new Snip.Collections.AppointmentsCollection()
      @appointments.reset options.appointments

これが依存する「予定」モジュールです。

// appointment.js.coffee
define ["app", "relational"], (App) ->
  class Snip.Models.Appointment extends Backbone.RelationalModel
    paramRoot: "appointment"

    defaults:
      time_block_type_code: "APPOINTMENT"
      start_time: null
      start_time_time: null
      start_time_ymd: null
      stylist: {}
      client: {}
      notes: ''

そして最後に、これが私のapplication.js.coffee

require
  paths:
    underscore: "lodash.min"
    appointment: "backbone/models/appointment"
    appointmentsRouter: "backbone/routers/appointments_router"
    relational: "backbone-relational"
  shim:
    "underscore":
      exports: "_"
    "backbone":
      deps: ["underscore"]
      exports: "Backbone"
    "relational":
      deps: ["backbone"]

requirejs ["appointmentsRouter"], (AppointmentsRouter) ->
  window.router = new Snip.Routers.AppointmentsRouter({appointments: []})
  Backbone.history.start()

ページをロードするとUncaught TypeError: undefined is not a functionbackbone.js1019行目になります。

「リレーショナル」シムを省略すると、代わりにになりUncaught TypeError: Cannot set property 'Relational' of undefinedますbackbone-relational.js。それが話している「未定義」はBackboneです。したがって、「リレーショナル」シムを省略してbackbone-relational.jsも、ロードされますが、バックボーンについてはわかりません。

これを修正するにはどうすればよいですか?

4

2 に答える 2

2

Require .. drop amd、backbonedid。でshim構成を使用できます。

https://github.com/DarrenHurst/BroadStreetを ご覧ください

シムの設定方法について。

于 2012-08-15T02:48:17.867 に答える
0

jQueryが必要であることがわかりました。

  shim:
    "underscore":
      exports: "_"
    "backbone":
      deps: ["underscore", "jquery"]
      exports: "Backbone"
    "relational":
      deps: ["backbone"]
于 2012-08-14T15:20:17.397 に答える