简体   繁体   English

骨干网:如何在与View关联的元素之外操作元素

[英]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.

相关问题 是否可以返回与元素ID相关联的Backbone View? - Is it possible to return the Backbone View associated with an element ID? 由多个外部元素触发的骨干视图 - Backbone View triggered by multiple outside elements om / react:在渲染目标元素之外操作元素 - om/react: manipulate elements outside the render target element 如何使AngularJS指令操纵与之关联的所有元素? - How do I make an AngularJS directive manipulate all elements associated with it? 如何更改与Backbone集合中的模型相关联的几个元素的css属性? - How to change css properties of several elements associated with models in a Backbone collection? 如何将 Backbone.View 绑定到 DOM 中类似元素列表中的“单个”DOM 元素 - How to bind a Backbone.View to a 'single' DOM element in a list of similar elements in the DOM 如何在BackBone视图上正确呈现$ el元素 - How to correctly render an $el element on a BackBone View 如何用div包装Backbone视图元素 - How to wrap a Backbone view element with a div 用于存储/检索Backbone.js的模式查看与dom元素关联的实例 - patterns for storing/retrieving Backbone.js View instances associated with dom elements 如何处理backbone.js中View之外的对象事件? - How to handle events of objects outside of a View in backbone.js?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM