为什么在 YUI javascript 中生成的链接无法在 Rails 中呈现?

发布于 2024-09-03 01:17:22 字数 1054 浏览 2 评论 0原文

使用YAHOO.widget.treeview生成一个包含三个级别数据的表:模块、子模块和详细信息。如果存在与详细信息行关联的图像,则 JavaScript 会生成一个链接:

"<td><a href=\"/screenshot/show/" + rowData.id + "\">Screenshot</a></td>"

该链接将附加到该行的 html 中。

url 已正确生成并显示链接。单击时,除了浏览器状态栏中出现“完成”一词外,不会发生任何事情。

我从不使用 javascript 的另一个页面调用完全相同的 url,并且屏幕截图页面按预期显示。

这是控制器。

类 ScreenshotController <应用程序控制器
定义显示 如果@detail.screen_path.length > 1 @imagePath = "#{RAILS_ROOT}" + “/private/#{Company.find(@detail.company_id).subdir}/” + "#{Project.find(@detail.project_id).subdir}/screenshot/" + “#{@detail.screen_path}” send_file (@imagePath, :type => 'image/jpeg', :disposition => 'inline') 结束
结尾 示例

网址: http://localhost:3004/screenshot/show/20854

此代码来自属于详细模型作品的 show.html.erb:

View', :controller => 'screenshot', :id => @detail.id, :action => 'show' %>

有什么想法吗???

Using YAHOO.widget.treeview to generate a table with three levels of data: module, submodule, and detail. If there is an image associated with a detail row the javascript generates a link:

"<td><a href=\"/screenshot/show/" + rowData.id + "\">Screenshot</a></td>"

that is appended to the html for the row.

The url is generated correctly and the link appears. When clicked nothing happens except the word 'Done' appears in the browser status bar.

Am calling the very same url from another page that does not use javascript and the screenshot page appears as expected.

Here is the controller.

class ScreenshotController < ApplicationController
def show
if @detail.screen_path.length > 1
@imagePath = "#{RAILS_ROOT}" +
"/private/#{Company.find(@detail.company_id).subdir}/" +
"#{Project.find(@detail.project_id).subdir}/screenshot/" +
"#{@detail.screen_path}"
send_file ( @imagePath, :type => 'image/jpeg', :disposition => 'inline')
end
end
end

A sample url: http://localhost:3004/screenshot/show/20854

This code from show.html.erb belonging to the detail model works:

View', :controller => 'screenshot', :id => @detail.id, :action => 'show' %>

Any ideas???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心舞飞扬 2024-09-10 01:17:22

也许有一些不需要的 js 会拦截您对生成链接的点击?

maybe there's some unwanted js that intercepts your click on generated links?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文