【发布时间】:2012-01-26 02:27:43
【问题描述】:
Rails 应用,学习 CoffeeScript 和 Backbone.js:
Uncaught TypeError: Cannot use 'in' operator to search for 'id' in easy
_.extend.setbackbone.js:205
Backbone.Modelbackbone.js:142
Gamegames.js:13
(anonymous function)games.js:34
jQuery.Callbacks.firejquery.js:1047
jQuery.Callbacks.self.fireWithjquery.js:1165
jQuery.extend.readyjquery.js:436
DOMContentLoadedjquery.js:924
这里是代码,games.js.coffee
jQuery ->
root = global ? window
class Game extends Backbone.Model
initialize: (@n, @diff) ->
console.log "--> Game.initialize()"
difficulty: ->
@diff
name: ->
@n
# Make class Game globally available
root.Game = Game
my_game = new Game('easy', 'hard')
console.log "my_game.name(), my_game.difficulty() --> #{my_game.name()}, # {my_game.difficulty()}"
我遗漏了一些东西,但无法弄清楚是什么......
【问题讨论】:
标签: ruby-on-rails-3.1 backbone.js coffeescript