[英]Hide div in Backbone.View
Why is the jquery selector not working? 为什么jquery选择器不起作用?
View 视图
Views.Now = Backbone.View.extend({
template:"mytemplate",
initialize:function () {
var self = this;
this.$el.find(".content").hide(); // selector is not working
}
});
Template: 模板:
<div id="now">
<p class="loader">Waiting for connection</p>
<div class="content">
<button>hello world</button>
</div>
Backbone views are only rendered after their render() method is called. 骨干视图仅在调用其render()方法后才呈现。 Before that, the view's element will still be empty, so the selector won't find anything. 在此之前,视图的元素仍然为空,因此选择器将找不到任何内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.