使用 chrome 开发工具。当我在应用程序中实例化一个视图时,我得到了这个......
new job.SearchView
SearchView
$el: jQuery.fn.jQuery.init[1]
cid: "view8"
el: HTMLDivElement
mbti: function (){ return fn.apply(me, arguments); }
options: Object
__proto__: ctor
从茉莉花我得到以下(和规格失败)
new job.SearchView
SearchView
$el: jQuery.fn.jQuery.init[0]
cid: "view17"
el: undefined
mbti: function (){ return fn.apply(me, arguments); }
options: Object
__proto__: ctor
为什么 el: 在茉莉花中实例化时未定义?
SearchView 是这样定义的...
jQuery ->
class SearchView extends Backbone.View
el: '#search'
template: JST['resume']
<snip>
@job = if window.job then window.job else {}
@job.SearchView = SearchView
和这样的规格......
describe 'Search View', ->
it 'should be defined', ->
expect(job.SearchView).toBeDefined()
beforeEach ->
@view = new job.SearchView()
describe 'render', ->
it 'should render the task', ->
$el = @view.render().$el
expect($el).toBeDefined()