RJS - slower than normal RHTML?

I know that isn’t supposed to be the case, and it usually isn’t, but
today, I’ve run across a situation where rendering the same partial
through RJS is taking about 5 times longer than rendering the partial in
the RHTML.

I have in my main RHTML

<%= render :partial => 'account_transactions/transaction', :collection => @account_transactions, :locals => {:nobalance => false, :goto => false} %>

By putting a benchmark around just the render line, it renders on
average 0.3 seconds.

Now I have a link on the page to go to another page (AJAX paging is the
thought) and everything processes in a timely fashion except this line:

page.replace_html “account_transactions”, :partial =>
‘account_transactions/transaction’, :collection =>
@account_transactions, :locals => {:nobalance => false, :goto => false}

It continually takes about 2.1 seconds.

Does anyone have any idea on why rendering the same thing would take
that much longer? The collection contains 25 objects and for each
object, two sub partials are rendered.

Thanks,
Trey

just a thought, but poge.replace_html not only generates the html from
the
partial, but also a little javascript to actually do the work of the
replace. It also has to go through all the generated html and escape it
i
believe, as it generates one long string which is used in the javascript
call…

Mark Van H. wrote:

just a thought, but poge.replace_html not only generates the html from
the
partial, but also a little javascript to actually do the work of the
replace. It also has to go through all the generated html and escape it
i
believe, as it generates one long string which is used in the javascript
call…

I put a firebug console.time around prototype’s Element.update and it
only took 128 ms. It seems that it’s the render in the
page.replace_html method call. I’ll look further.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs