Mse*_*enb 4 iframe layout ruby-on-rails render ruby-on-rails-3.1
所以我有一个基本的布局文件:
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<%= stylesheet_link_tag "logged_out" %>
<%= javascript_include_tag "application" %>
<%= stylesheet_link_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css" %>
</head>
<body>
<!-- header stuff here -->
<%= yield %>
<!-- footer stuff here -->
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
和任何正常的HTML一样好.但是,如果我将这样的iframe添加到视图中:
<iframe id="form" height="480" width="320" src="/mobile_preview/preview"/>
Run Code Online (Sandbox Code Playgroud)
当我渲染页面时,所有内容都会呈现,直到iframe,但是yield之后的页脚内容不会呈现.有没有人遇到过这个?
编辑:正如其中一个答案所指出的(谢谢!),我在最初的问题中的收益率陈述是错误的.我的代码中的yield语句是正确的,但是当转移到stackoverflow时它是一个错字.
注意:如果您尝试复制iframe正在使用jquery mobile.
MBO*_*MBO 14
问题是你如何包括<iframe>.你认为你包括自闭标签,它就在那里结束.但是你没有把你的页面作为XML发送,并且HTML没有自闭标签的概念,最后它只是垃圾.所以你的:
<iframe id="form" height="480" width="320" src="/mobile_preview/preview"/>
Run Code Online (Sandbox Code Playgroud)
真的解释为:
<iframe id="form" height="480" width="320" src="/mobile_preview/preview">
Run Code Online (Sandbox Code Playgroud)
页面的其余部分被解释为<iframe>标记内的忽略内容.这就是为什么你不应该在HTML文档中使用自闭标签 - 它们并不像你认为的那样工作.
将其更改为:
<iframe id="form" height="480" width="320" src="/mobile_preview/preview"></iframe>
Run Code Online (Sandbox Code Playgroud)
如果您使用Firebug或Chrome Inspector查看已解析的DOM树,则可以找到它.
作为奖励:它与Rails无关,服务器返回响应就像以前一样,你可以在日志中看到它.这只是浏览器如何解释标记的问题.