<%= stylesheet...">

Rails 3.1 Having an iframe in still image view

So, I have a main layout file:

<!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> 

And with any normal html its fine. However, if I add in an iframe like this, to the view:

 <iframe id="form" height="480" width="320" src="/mobile_preview/preview"/> 

When I create the page, everything is processed before the iframe, but the footer after the crop does not display. Has anyone come across this before?

EDIT: As one of the answers said (thanks!), My exit statement in my original question was wrong. My yield statement in my code is correct, although it was a typo when porting to stackoverflow.

NOTE. If you are trying to replicate an iframe, use jQuery mobile.

+4
source share
2 answers

The problem is how you include the <iframe> . You think you have included a self-closing tag, and it ends there. But you do not send your page as XML, and HTML does not have the concept of self-closing tags, it is just rubbish at the end. So yours:

 <iframe id="form" height="480" width="320" src="/mobile_preview/preview"/> 

really interpreted as:

 <iframe id="form" height="480" width="320" src="/mobile_preview/preview"> 

and the rest of the page is interpreted as ignored content inside the <iframe> . That's why you shouldn't use self-closing tags in an HTML document - they really don't work the way you think they work.

Change it to:

 <iframe id="form" height="480" width="320" src="/mobile_preview/preview"></iframe> 

You could find it if you looked at the parsed DOM tree with Firebug or Chrome Inspector.

As a bonus: it has nothing to do with Rails, the server returns the response as before, you can see it in the logs. It's just a matter of how your markup is interpreted by browsers.

+14
source

You have an error while cloning a ruby ​​code.

 <%= yield => 

Right

 <%= yield %> 
+2
source

All Articles