4

So I have a basic 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 a view:

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

When I render the page everything is rendered up until the iframe, but the footer stuff after yield doesn't render. Has anyone run into this before?

EDIT: As one of the answers pointed out (thank you!), my yield statement in my initial question was wrong. My yield statement in my code is correct though, it was a typo when transferring to stackoverflow.

NOTE: If you are trying to replicate the iframe is using jquery mobile.

1
  • look at the rendered page source - the iframe shouldn't get fetched until after the page has loaded. Commented Sep 12, 2011 at 19:07

2 Answers 2

15
+50

The problem is how you include <iframe>. You think you included self-closing tag, and it ends there. But you don't send your page as XML, and HTML doesn't have concept of self-closing tags, it's just garbage at the end. So your:

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

is really interpreted as:

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

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

Change it to:

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

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

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks MBO! Stackoverflow is going to make me wait 22 hours, but I'll award you the bounty when I can.
@MBO, thank you so much.. i am struggling with this irritating problem for quite some time.. what a silly mistake :)
2

You have wrong on clossing ruby code place

<%= yield => 

The correct is

<%= yield %> 

1 Comment

Woops that was a typo when simplifying for SO. My real code has the correct yield. I'll update the question

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.