0
我剛剛觀看了backbone.js railscasts,並且當名稱不存在但沒有收到錯誤警報,但在服務器端發生錯誤。Backbone.js和Rails 3.2
使用im軌3.2.8和骨幹-上軌0.9.2.3
在網絡控制檯它確實是那裏有一個錯誤與API /項,並在響應那裏有錯誤鍵,狀態,但當我單擊窗體上的任何內容時,仍然沒有任何提醒。
這是我的代碼...請幫我弄清楚什麼可能是錯的!
class Raffler.Views.EntriesIndex extends Backbone.View
template: JST['entries/index']
events:
'submit #new_entry': 'createEntry'
'click #draw': 'drawWinner'
initialize: ->
@collection.on('reset', @render)
@collection.on('add', @appendEntry)
render: =>
$(@el).html(@template())
@collection.each(@appendEntry)
this
appendEntry: (entry) =>
view = new Raffler.Views.Entry(model: entry)
@$('#entries').append(view.render().el)
drawWinner: (event) ->
event.preventDefault()
@collection.drawWinner()
createEntry: (event) ->
event.preventDefault()
attributes = name: $('#new_entry_name').val()
@collection.create attributes,
wait: true
success: -> $('#new_entry')[0].reset()
error: @handleError
handleError: (entry, response) ->
if response.status == 422
errors = $.parseJSON(response.responseText).errors
for attribute, messages of errors
alert "#{attribute} #{message}" for message in messages
謝謝!
是!就是這樣......謝謝你的幫助!我不能相信我錯過了:S ... – maumercado