1
使用rails 3.1資產管道和coffeescript。 我已經使用rails-backbone gem來幫助我,並且一直在爲我工作,直到我試圖將事件提交給我的觀點。只要我把事情的事件屬性JST不會呈現(它沒有它):Rails 3.1 View中的Backbone JST將不會編譯事件
Headspace.Views.Shows ||= {}
class Headspace.Views.Shows.IndexView extends Backbone.View
template: JST["backbone/templates/shows/index"]
el: '#show_listing'
initialize:() ->
@collection = @options.collection
this.render()
events:
'click .show_header' : 'show_details'
show_details =()->
alert('action')
render: ->
$(@el).html(@template({collection:@collection}))
我也試了一個空的事件屬性(不編譯,除非我把空{})確實呈現JST。我認爲,el被定義爲一個字符串,而不是一個jQuery元素(帶有$()),直到渲染函數。如果我做具體說明:
el: $('#show_listing')
和:
render: ->
el.html(@template({collection:@collection}))
的JST不會編譯。
當你說JST不編譯你的意思是你在服務器或客戶端上出現錯誤?什麼是錯誤? – Julien
這是使用jst工作的沮喪之源。沒有錯誤,它只是不渲染。我使用ejs gem來處理模板,但我沒有在任何地方發現任何錯誤(即使在螢火蟲中也沒有)。它只是不渲染。 –
猜我不應該說它不編譯,一切都得到了很好的處理,只是沒有渲染。 「編譯」或處理的JST在螢火蟲中輸出很好。 –