使用Dojo连接到特定的选项卡/ contentpane [英] Linking to a specific tab / contentpane with Dojo

查看:208
本文介绍了使用Dojo连接到特定的选项卡/ contentpane的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从html网站上的链接导航到另一个具有两个不同选项卡的TabContainer。

I want to navigate from a link on a html site to another where a TabContainer with two different tabs is located.

我默认选择了一个选项卡(其中我想保留)在目标html文件。

I have one tab selected by default (which I want to keep) in the destination html file.

如何将链接放在一起呢?我在网上发现了几个文件,但没有任何作用。所以可能有人需要向我解释这个愚蠢的方式。

How do I have to put the link so that this is working? I found several documents on the net but nothing works. So probably someone needs to explain this to me the dumb way.

这是目的地TabContainer:

Here is the destination TabContainer:

<div dojoType="dijit.layout.TabContainer" region="center" tabStrip="true">
<div dojoType="dijit.layout.ContentPane" title="Contact" selected="true">
some text
</div>
<div dojoType="dijit.layout.ContentPane" title="Imprint" selected="true">
some text
</div>

我想将一个链接自动导航到标题印记。

I want to place a link to autmatically be navigated to the title "Imprint".

有人可以帮忙吗?

非常感谢所有最好的
TTP

Thanks a lot and all the best TTP

推荐答案

您可以从javascript中选择它,也可以从选择的为您的服务器生成标签的标记属性到 true (您需要将另一个设置为 false )。第二个选择取决于您的服务器技术。

You can either select it from javascript, or generate the markup for the tab from your server with the selected attribute to true (you'll need to set the other to false). This second alternative, depends on your server technology.

对于第一个选项,将id添加到容器和选项卡,并在页面加载完成时选择该选项卡。如下:

For the first option, add ids to the container and tabs and select the tab when the page finished loading. Something like:

<div id="tabContainer" dojoType="dijit.layout.TabContainer" region="center" tabStrip="true">
  <div id="tab1" dojoType="dijit.layout.ContentPane" title="Contact" selected="true">
    some text
  </div>
  <div id="tab2" dojoType="dijit.layout.ContentPane" title="Imprint" selected="false">
    some text
  </div>
</div>

<script>
  dojo.ready(function() {
    dijit.byId('tabContainer').selectChild(dijit.byId('tab2'));
  });
</script>

如果要动态选择任一选项卡,则需要传递某种参数您网页的网址您可以使用查询参数(符号后的变量)或散列片段(之后的任何内容)。查询参数可以从服务器和javascript中读取。哈希片段,只能从javascript。

If you want to dynamically select either tab, you'll need to pass some kind of parameter in the URL to your page. You can use a query parameter (variables after the ? symbol) or a hash fragment (anything after #). Query parameter you can read both from the server and from javascript. Hash fragments, only from javascript.

您可以通过检查 位置 对象。例如,使用哈希片段,您可以链接到您的页面,如 http://host/page.html#imprint 。然后在上面的< script> 标签中:

You can access those parameters by inspecting the location object. For example, using a hash fragment, you'd link to your page like http://host/page.html#imprint. Then in the <script> tag above:

<script>
  dojo.ready(function() {
    if (location.hash == '#imprint') {
      dijit.byId('tabContainer').selectChild(dijit.byId('tab2'));
    }
  });
</script>

对于查询参数,还请参阅 dojo.queryToObject()

For query parameters, also see dojo.queryToObject().

这篇关于使用Dojo连接到特定的选项卡/ contentpane的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆