[英]Backbone: how to manipulate elements outside the element associated with View
My html structure is: 我的html结构是:
<div id="header">
</div>
<div id="screen">
</div>
My Backbone View is associated with screen. 我的主干视图与屏幕关联。 How to hide/show element in header? 如何隐藏/显示标题中的元素?
The direct answer is: 直接的答案是:
There's nothing special backbone will do for you here. 这里没有什么特殊的骨干可以为您服务。 Do it like you would do had backbone not existed at all. 像没有骨干网一样做。
The correct answer is: 正确的答案是:
If you need to manipulate UI elements outside of your view model, your view model is wrong - fix it. 如果您需要在视图模型之外操作UI元素,则视图模型是错误的-对其进行修复。
According to the backbone structure & logic - your headerview or screenview should throw an event, in which header view should listen to. 根据主干结构和逻辑-您的headerview或screenview应该抛出一个事件,在该事件中header视图应该侦听。 If that event happens - then headerview should hide itself. 如果该事件发生-那么headerview应该隐藏自己。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.