轨道路由
我在 Rails 上构建了一个新的门户,可以通过以下方式访问:https://xyz.com
是: 1.) 它有 2 个选项卡 – “ShipmentInfo”、“Aging Shipments Dashboard” 均使用
<li> tags and YUI library’s tabview.
<ul class="yui-nav">
<li id="tab1" class="selected"><a href="#tab1">Shipment Info</a></li>
<li id="tab2"><a href="#tab2">Aging Shipments Dashboard</a></li>
</ul>
2.) 当我单击“Aging Shipments Dashboard”选项卡时 – url 应该是 – https://xyz.com/#tab2 但您只能看到 https://xyz.com。 我认为这是因为选项卡的客户端实现。
3.) 单击该选项卡中的“当前摘要”按钮后,我得到了相应的结果,但不是显示设置为“时效货件仪表板”的活动选项卡,而是始终设置为“ShipmentInfo”选项卡。
如何设置 activeTab 将结果获取到已发出请求的相应选项卡? 所有表单请求都使用 GET 方法。
或者有没有一种方法可以根据 activeTab 应设置为“时效货运仪表板”的参数,在 paths.rb 中明确提及?
谢谢, 拉贾。
I have built a new portal on Rails which can be accessed as say: https://xyz.com
The problem with this is:
1.) It has 2 tabs – “ShipmentInfo” , “Aging Shipments Dashboard” both implemented using
<li> tags and YUI library’s tabview.
<ul class="yui-nav">
<li id="tab1" class="selected"><a href="#tab1">Shipment Info</a></li>
<li id="tab2"><a href="#tab2">Aging Shipments Dashboard</a></li>
</ul>
2.) When I click on “Aging Shipments Dashboard” tab – url should be – https://xyz.com/#tab2 but you get to see only https://xyz.com . I presume it because of client side implementation of Tabs.
3.) After I click on “Current Summary” button in that tab, I get the corresponding results but instead of showing me the active Tab set to “Aging Shipments Dashboard” it is always set to “ShipmentInfo” tab.
How can I set the activeTab on getting the results to corresponding Tab from which request has been placed ? All form requests use GET method.
Or is there a way wherein I can explicitly mention in routes.rb, basing on the params that the activeTab should be set to “Aging Shipments Dashboard”?
Thanks,
Raja.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,无论 YUI 将
ul
转换为一组选项卡,都可能与li< 内的
href
无关。 /代码>。 我认为您应该验证生成选项卡的使用语法。继续,
href
链接仅指向当前页面内的锚点。 这意味着客户端(浏览器)不必发送 HTTP 请求来重新获取当前页面。 我不认为现代浏览器会这样做。 我怀疑他们发送了 URL 的锚点部分(#
后面的部分),因为 HTTP 服务器不关心该信息。这意味着,当用户单击选项卡时,您的 Rails 应用程序永远不会收到通知,并且永远不会获取
#
之后的 URL 部分。 所以你不能在路由表中放置任何关于它的规则。编辑:我忘了告诉你到底应该发生什么。
li
的 onClick,根据您的描述,它看起来像一个选项卡。div
,并且它的id
可能是tab2
或其他内容。display
属性完成的,将其设置为display: none
。display: block
或类似的东西来完成。As far as I can tell, whatever the YUI does to transform that
ul
into a set of tab probably has nothing to do with thehref
s inside theli
. I think you should verify the usage syntax for producing your tabs.Moving on, the
href
links only point to anchors within the current page. Which means the client (browser) doesn't have to send an HTTP request to re-get the current page. I don't think that modern browsers ever do. I doubt they send the anchor part of the URL (the part after the#
) since the HTTP server doesn't care about that information.What this amounts to, is that your rails application is never notified about when the user clicks on a tab, and never gets the part of the URL after
#
. So you can't put any rules about it in the routing table.EDIT: I forgot to tell you what really should happen.
li
, which looks like a tab, from your description.div
that contains the 2nd tabs content, and it could have anid
oftab2
or something.display
property, setting it todisplay: none
.display: block
or something simliar.是的。 您的routes.rb 文件末尾可能已经有这些行:
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
将它们更改为:
map.connect '#:controller'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
这样您就可以将两个变量定义为 Rails 应用程序中的不同控制器。 您也可以通过两个操作来执行相同的操作,但这是您的决定。
Yes. You probably already have these lines at the end of your routes.rb file:
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
Change them to:
map.connect '#:controller'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
This way you can define the two variables as different controllers within the rails app. You could probably do the same thing as two actions too, but that's your call.