在我的主干 app的完稿中,我想用空子来填表的其余部分,供改换头的浏览,但我知道要增加多少几行。 我尝试了<条码>。 0. 谁知道如何这样做? 我也想增加太多,以便不引入滚动酒吧。
var bar = Backbone.View.extend({
initialize: function(){
_.bindAll(this, "render");
},
render: function(){
var html = "<h1>Hi!</h1>";
$(this.el).html(html);
var myWidth = this.el.width();
alert(myWidth);
return this;
}
});
var foo = Backbone.View.extend({
el: $( #myElement ),
initialize: function(){
_.bindAll(this, "render");
this.subview = new bar();
},
render: function(){
$(this.el).append(this.subview.render().el);
return this;
}
});
Solution for those stuck with the same problem as I had: You have to wait for the elements to be fully attached to the dom in order to get height/width info. In order to resolve this I added a postrender call after the render is fully done which went back and handled any small details.