Ruby on Rails Wednesday, January 2, 2013

This is what I am using in one of my projects. It should't be problem to
make it in erb.

--------------------------------
def iframe_helper(if_name)

opts = { controller: 'somectrl', action: 'index', id: @record.id,
iframe: "if_#{if_name}" }
html = "<iframe class='iframe_embedded' id='if_#{if_name}'
name='if_#{if_name}'></iframe>"


html << <<EOJS
<script type="text/javascript">
$(document).ready( function() {
$('#if_#{if_name}').attr('src', '#{url_for(opts)}');
});
</script>
EOJS

html.html_safe
end
----------------------------------
In short:
opts = Hash to make url to display in frame.

iframe html code. if_name=name of iframe.

javascript part which loads iframe code by calling url when document is
loaded. You need jquery for all this to work.

by
TheR

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment