【发布时间】:2013-01-13 20:49:07
【问题描述】:
我有一个创建弹出窗口的 link_to。它适用于某些页面,但是当我在其他页面上单击它时,它会转到错误的 URI。我的应用架构有问题吗?我希望所有链接都路由到
http://localhost:3000/microposts/361/into_it.
SHARED/_feed_item.html.erb---这行代码路由正确:
<%= link_to "#{feed_item.votes_for} Into it!", into_it_micropost_path(feed_item.id), :onclick => "javascript:window.open('microposts/#{feed_item.id}/into_it','popup','width=350,height=300,top=315,left=200');", id: "feeditemlikes_#{feed_item.id}", remote: true %>
用户/_vote_feed_item.html.erb--- 在类似页面上,它会路由到
http://localhost:3000/users/1/microposts/361/into_it
<%= link_to "#{vote_feed_item.votes_for} Into it!", into_it_micropost_path(vote_feed_item.id), :onclick => "javascript:window.open('microposts/#{vote_feed_item.id}/into_it','popup','width=350,height=300,top=315,left=200');", id: "feeditemlikes_#{vote_feed_item.id}", remote: true %>
MICROPOSTS/_micropost.html.erb---在配置文件页面上它路由到
http://localhost:3000/users/microposts/361/into_it
<%= link_to "#{micropost.votes_for} Into it!", into_it_micropost_path(micropost.id), :onclick => "javascript:window.open('microposts/#{micropost.id}/into_it','popup','width=350,height=300,top=315,left=200');", id: "feeditemlikes_#{micropost.id}", remote: true %>
实际上,问题似乎出在 javascript 弹出代码上,有什么提示吗?
【问题讨论】:
-
你需要'remote: true'吗?
-
我需要它,所以页面不会刷新/更改
标签: javascript ruby-on-rails routes link-to