[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Rails problem with page.replace

RaW

12/13/2006 9:41:00 PM

Hi,
I'm going to add some functionality to my application. I need to replace
two page's elements with each other.
All works fine, but I would like to refresh only changed elements, not
all on the page.
I think ajax should hel me but I have a problem with rendering the
replaced elements.

In the .rjs file I have:

page.replace @photo1.id.to_s, '<h1>test</h1>'

and this works - it pretty replace appropriate element with given html
string and also render the page correctly.

But this one, doesnt work at all.
page.replace @photo1.id.to_s, :partial => "replace2"

In the _replace2.rhtml I have a temporary text like:
<h1>test</h1>

Does someone know what could be the reason of this? Why :partial makes
that nothing is rendered?

Thanks in advance for any answers.

--
RaW
2 Answers

Tim Pease

12/14/2006 8:47:00 PM

0

On 12/13/06, RaW <raw@mlyniec.gda.pl> wrote:
> Hi,
> I'm going to add some functionality to my application. I need to replace
> two page's elements with each other.
> All works fine, but I would like to refresh only changed elements, not
> all on the page.
> I think ajax should hel me but I have a problem with rendering the
> replaced elements.
>
> In the .rjs file I have:
>
> page.replace @photo1.id.to_s, '<h1>test</h1>'
>
> and this works - it pretty replace appropriate element with given html
> string and also render the page correctly.
>
> But this one, doesnt work at all.
> page.replace @photo1.id.to_s, :partial => "replace2"
>
> In the _replace2.rhtml I have a temporary text like:
> <h1>test</h1>
>
> Does someone know what could be the reason of this? Why :partial makes
> that nothing is rendered?
>
> Thanks in advance for any answers.
>

Try posting this question on the Ruby on Rails maling list. They'll be
able to answer your question much more quickly.

Blessings,
TwP

RubyTalk@gmail.com

12/15/2006 7:23:00 PM

0

Try

page.replace_html @photo1.id.to_s, :partial => "replace2"


I do not use .rjs files. I use the inline formating.

def action
if request.xhr?
render :update do |page|
page.replace_html @photo1.id.to_s, :partial => "replace2"
end
return
end
end

Sbeckeriv

On 12/13/06, RaW <raw@mlyniec.gda.pl> wrote:
> Hi,
> I'm going to add some functionality to my application. I need to replace
> two page's elements with each other.
> All works fine, but I would like to refresh only changed elements, not
> all on the page.
> I think ajax should hel me but I have a problem with rendering the
> replaced elements.
>
> In the .rjs file I have:
>
> page.replace @photo1.id.to_s, '<h1>test</h1>'
>
> and this works - it pretty replace appropriate element with given html
> string and also render the page correctly.
>
> But this one, doesnt work at all.
> page.replace @photo1.id.to_s, :partial => "replace2"
>
> In the _replace2.rhtml I have a temporary text like:
> <h1>test</h1>
>
> Does someone know what could be the reason of this? Why :partial makes
> that nothing is rendered?
>
> Thanks in advance for any answers.
>
> --
> RaW
>
>