Forum: Ruby on Rails Problem with render :partial ... :collection

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B1415e872f86d771167c48a0832f583b?d=identicon&s=25 Laurent (Guest)
on 2007-05-15 16:44
(Received via mailing list)
Hello,

I 'm currently developing a fully ajaxified Portal with RoR for a
client.

In the page, i have an In Place Editing Area :
Clicking on the area (div), replace it with a content coming from a
Partial (i've extended the component InPlaceEditor from controls.js
for this)..This first Partial is called A

In this partial A.rhtml, i render a second 'inner' partial as :
render :partial=> 'display_row', :collection=>@my_collection

My 'display_row' inner partial includes the following code :
<div id='myrow'>
<div id='mycell1'>blah blah</div>
<div id='mycell2'>blah blah</div>
</div>
<script>
... my source here ....
</script>

But when testing in the browser, and checking generated code with
Firebug, i do not see any node <script> in my HTML page...seems to
have been skipped


This same 'display_row' inner partial is reused directly from RJS (in
the controller) :
render :update do |page|
      page.insert_html :bottom, "container", :partial => "display_row"
end

In this second case it works..i can see the node <script> in the
generated HTML

Are there limitations with partials rendered from another partial?

Thanks

Laurent
83ca41657a99b65d99889abe712ba5e2?d=identicon&s=25 Jason Roelofs (Guest)
on 2007-05-15 17:33
(Received via mailing list)
When rendering through partials, <script> tags are stripped out of the
resulting source and the javascript inside said tags is executed (unless
of
course evalScripts is set to false, default is obviously true).

I wouldn't worry about it too much, though do make note that if you are
trying to define a javascript function in a partial's script tags, it
most
likely won't work (at least, I haven't figured out how). So in this case
you
need to define the function in the initial page HTML, or in javascript
includes.

Jason
B1415e872f86d771167c48a0832f583b?d=identicon&s=25 Laurent (Guest)
on 2007-05-16 07:11
(Received via mailing list)
Jason,

I suppose doing a Ruby helper on top of my Javascript won't help
In any case, the generated <script> tag will be stripped out

Laurent
This topic is locked and can not be replied to.