Rails link_to 锚定在部分内
在我的 Rails 3 应用程序中,我有一个 link_to
,它将用户从其个人资料页面带到设置页面。设置页面包含用于编辑配置文件的表单 :partial
。我想做的是让配置文件中的 link_to
将用户带到表单部分中的锚点。我已经尝试过,但遇到了麻烦。
作为我的 link_to
我有:
<%= link_to('Visit the info section', settings_path, {:anchor => 'info'}) %>
在 settings_path 中是 <%= render :partial =>; 'profiles/edit_settings_form' %>
在该部分中是:
<div class="infoBlock" anchor="#info">
</div>
我有一个我认为导致错误的设置路径:
match "/settings" => "settings#show", :as => 'settings'
我尝试将锚点的另一个匹配项添加到“profiles#edit_settings_form”,但它没有工作。有什么想法吗?
In my Rails 3 app I have a link_to
that takes the User from their profile page to the settings page. The settings page contains a form :partial
for editing a profile. What I'd like to do is have the link_to
in the Profile take the User to an anchor in the form partial. I've given it a go but am having trouble.
As my link_to
I have:
<%= link_to('Visit the info section', settings_path, {:anchor => 'info'}) %>
Within settings_path is <%= render :partial => 'profiles/edit_settings_form' %>
Within that partial is:
<div class="infoBlock" anchor="#info">
</div>
I have a route for settings that I thought was causing the error:
match "/settings" => "settings#show", :as => 'settings'
I tried adding another match for the anchor to "profiles#edit_settings_form" but it didn't work. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不是对页面进行锚定的正确方法。正确的语法类似:
现在,当您使用 pagename#anchor 进行页面访问时,它会将您重定向到该块。例如:
is not proper way to do an anchor to a page. Correct syntax is something similar:
Now when you got to page with pagename#anchor, it redirects you to that block. For example: