dojo 在另一个内容窗格处于液态时显示/隐藏一个内容窗格
几周来我一直在努力破解这个难题,所以我不确定这是不可能的,还是我缺乏编码能力……或者两者兼而有之。我不是程序员,而且是 Dojo Toolkit 的新手。
我有一个使用 BorderContainer 布局的网站。我正在尝试创建一种效果,可以使用按钮打开和关闭包含控件的下拉类型框。我需要在页面加载时隐藏此下拉列表,然后在单击按钮时打开。
我的问题是,当我打开下拉菜单时,它将其下方的内容窗格推离浏览器窗口的底部。当下拉列表打开时,我需要下部的 ContentPane 保持在浏览器窗口的剩余空间内。此外,我希望下拉列表位于其下方内容的可滚动容器之外,这就是为什么我将其设置为位于其下方的嵌套 BorderContainer 之外。
我创建了代码的简化版本来演示我的挑战(请参阅下面的链接)。如果加载页面,您可以看到中心的 ContentPane 滚动内容。但是,如果您单击该按钮,则会在内容上方展开一个下拉 div。然后,当您滚动时,您会注意到您看不到完整的窗格,因为它位于浏览器窗口底部下方的无人区。我假设因为 div 设置为在加载时显示:无,所以页面加载时不考虑它的大小。然后,当您通过按按钮打开它时,它的大小是累加的,并且下面的窗格不知道如何调整大小或考虑新元素。
我尝试过使用可见性属性,但是当 div 仍然关闭时,会留下一个间隙。我修改了一些控制高度的代码,显示出承诺,但每个下拉框的大小都不同,所以我更喜欢将高度设置为“自动”而不是指定的像素大小。
有谁知道我如何才能做到这一点,以便下部窗格能够适应空间而不推开屏幕?
以下是该页面的示例:
http://equium.com/scaffold.html
(我遇到了一些问题尝试在此处插入完整的 HTML 页面作为代码示例,因此如果这是处理它的更好方法,并且有人可以让我知道嵌入所有代码的最佳方法,我将不胜感激。)
谢谢您的帮助,我真的很感激任何人的反馈。
I've been struggling for weeks trying to crack this nut so I'm not sure if it's impossible, or if it's my lack of coding chops... or both. I'm not a programmer and I'm a newbie to Dojo Toolkit.
I have a site using the BorderContainer layout. I'm trying to create an effect where I can use a button to open and close a dropdown type box that will contain controls. I need this dropdown to be hidden on page load, and then open when you click the button.
My problem is that when I open the dropdown, it pushes the content pane below it off the bottom of the browser window. I need the lower ContentPane to stay fit within the remaining space of the browser window when the dropdown opens. Additionally, I want the dropdown to sit outside of the scrollable container for the content below it, which is why I have it set up to sit outside a nested BorderContainer below it.
I've created a simplified version of the code to demonstrate my challenge (see link below). If you load the page you can see the center ContentPane scrolls the content. But, if you then click on the button, a dropdown div expands above the content. Then when you scroll, you'll notice that you can't see the full pane because it's in no-man's-land below the bottom of the browser window. I assume that because the div is set to display:none on load, it's size is not accounted for on page load. Then, when you open it by pressing the button, it's size is additive and the pane below doesn't know how to resize or account for the new element.
I've tried using the visibility attribute, but that leaves a gap for the div when it's still closed. I've tinkered with some code that controls the height that shows promise, but each of my dropdown boxes will be different sizes so I'd prefer that the height be set to "auto" rather than a specified pixel size.
Does anyone have any idea how I can accomplish this so that the lower pane will fit in the space without pushing off the screen?
Here's a sample of the page:
http://equium.com/scaffold.html
(I had some problems trying to insert the full HTML page here as a code sample so if that's a preferable way to handle it, and someone can let me know the best way to embed all of that code, I'd appreciate it.)
Thanks is advance, I'd really apprecaite anyone's feedback.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可能想看一下
dojox.layout.ExpandoPane
(尽管请注意,我认为它只在顶部和左侧区域正常工作一段时间)。另外,我建议稍微简化/改变您的布局。请参阅此处的示例:
http://jsfiddle.net/taFzv/
(可能需要一些调整才能获得正是您想要的。)
您遇到的真正问题可能是 BorderContainer 不知道视图的某些部分已调整大小。 ExpandoPane 通过告诉 BorderContainer 在动画完成后重新布局来解决这个问题。
You might want to take a look at
dojox.layout.ExpandoPane
(though be warned I think it has only worked properly for top and left regions for a while).Also, I'd suggest simplifying/altering your layout a bit. See example here:
http://jsfiddle.net/taFzv/
(It'd probably need some tweaking to get exactly what you want.)
The real issue you're having is probably that the BorderContainer has no idea that parts of the view resized. ExpandoPane takes care of that by telling the BorderContainer to re-layout after its animation completes.
它在IE8.0下运行。当下拉框打开时,只需在页面上按住鼠标并拖动到底部,您就可以看到内容被推送到页面外。看起来浏览器无法检测到它,也无法将其添加到“滚动条”帐户。
It works under IE8.0. When dropdown box open, just keep pressing mouse from page and drag to bottom, you could see the content was pushed to out of page. It looks the browser could not detect it and could not add it to "scroll bar" account.
我建议取出除顶级容器(以 mainPage 作为 id 的容器)之外的所有 BorderContainer。
将您的 {stuff here} div 放入 mainPage BorderContainer 中,位于带有“关闭/打开”按钮的 ContentPane 后面。确保将其设置为 dojotype dijit.layout.ContentPane,设置布局优先级,并将区域设置为顶部。单击打开/关闭按钮时将高度设置为 0/x,而不是设置显示。
再次尝试您的页面。如果这不能解决问题,您可能需要调用布局、调整大小或两者来指示 BorderContainer 它需要评估其所有子项并正确调整“中心”窗格的大小。类似于 dijit.byId("mainPage").layout();在更改任何 BorderContainer 子项的高度后,每当有人按下“关闭/打开”按钮时,请执行此操作。
I would suggest taking out all BorderContainers except your top level one, the one with mainPage as the id.
Place your {stuff here} div into the mainPage BorderContainer, after the ContentPane with the Close/Open button. Make sure you make it dojotype dijit.layout.ContentPane, set up layoutpriority, and set region to top. Set the height to 0/x when clicking the Open/Close button, instead of setting display.
Try your page again. If that doesn't fix it, you probably need, a call to layout, resize, or both to indicate to the BorderContainer that it needs to evaluate all its children and size the "center" pane properly. Something like dijit.byId("mainPage").layout(); Do this any time someone presses the Close/Open button, after you have changed the height of any BorderContainer children.
也许 dijit.form.DropDownButton 会满足您的需求。单击该按钮时,会显示一个工具提示,可以填充您想要的任何内容。正如您所指定的,只有当您单击按钮时才会显示下拉工具提示,并且它根本不会干扰底层布局。工具提示位于页面的“顶部”。
Maybe the dijit.form.DropDownButton would fit your needs. When click the button a tooltip is displayed that can be filled with any content you want. Just as you specified, the dropdown tooltip is only displayed when you click the button, and it doesn't mess with the underlying layout at all. The tooltip sits "on top" of the page.