In my application I have a view which comes bound to an html element already in the DOM
var myView = Backbone.View.extend({
...
el: '#myElement',
...
});
I've a problem with the following jasmine test:
beforeEach(function(){
//fixiture created with jasmin-jquery.js plugin
setFixtures('<div id="myElement"></div>');
this.myView = new MyView({model: new Model());
});
describe('when instantiated', function(){
it('should be associated to #myElement', function(){
expect(this.app.el).toBeDefined();
expect(this.app.el).toBe($('#myElement'));
});
});
the test fails and it turns out that this.app.el == ''
Am I wrong or this shouldn't be the correct behavior?
您的装置不应该包含“myElement”ID 以便您的视图可以连接它吗?
setFixtures('<div id="myElement"></div>');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.