Forum: Ruby on Rails ajax question, not so basic I guess...

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.
Daniel (Guest)
on 2006-04-07 00:07
Hey

Is there a ajax method that triggers when the page is fully loaded?

I want to be able to specify which div to update, something like this:

<%= on_page_loaded(
                   :update => "generatedimage",
                   :url => { :action => :generateimage })
%>

What I'm trying to do is load a page with a animated gif image saying
"custom graphics is being generated...". When this page has finished
loading, I want to call a remote method that generates a custom image
and returns it, replacing the first image. The generation of the custom
image takes a few seconds, thats why I want to display the first
animated gif.
(I want the replacement of the image to be done using ajax)

Can this be done?

Thank you guys for this awesome forum :)

//Daniel
=?utf-8?b?U8OpYmFzdGllbg==?= Grosjean (Guest)
on 2006-04-07 03:17
(Received via mailing list)
Daniel <big@...> writes:

> Is there a ajax method that triggers when the page is fully loaded?
>
> I want to be able to specify which div to update, something like this:
>
> <%= on_page_loaded(
>                    :update => "generatedimage",
>                    :url => { :action => :generateimage })
> %>
>
...
> (I want the replacement of the image to be done using ajax)


I guess a call to window.onload from javascript may solve your problem.
Daniel (Guest)
on 2006-04-07 13:47
=?utf-8?b?U8OpYmFzdGllbg==?= Grosjean wrote:
> Daniel <big@...> writes:
>
>> Is there a ajax method that triggers when the page is fully loaded?
>>
>> I want to be able to specify which div to update, something like this:
>>
>> <%= on_page_loaded(
>>                    :update => "generatedimage",
>>                    :url => { :action => :generateimage })
>> %>
>>
> ...
>> (I want the replacement of the image to be done using ajax)
>
>
> I guess a call to window.onload from javascript may solve your problem.

Is it really possible to call a remote method from a javascript?
Can anybody point me in the right direction?

This cant be that hard... how do you usually solve these kind of
problems?


//Daniel
Daniel (Guest)
on 2006-04-07 14:13
Ok, i take it ajax cant do the magic for me...

I think I'll go with a pure javascript solution like this
http://siter.com.au/dmitry/images.html

//Daniel
Alex Y. (Guest)
on 2006-04-07 14:15
(Received via mailing list)
Daniel wrote:
> =?utf-8?b?U8OpYmFzdGllbg==?= Grosjean wrote:
>>I guess a call to window.onload from javascript may solve your problem.
>
>
> Is it really possible to call a remote method from a javascript?
That would be the point :-)

> This cant be that hard... how do you usually solve these kind of
> problems?
window.onload=function(){
<%= remote_function(:update => 'generatedimage',
   :url => {:action => 'generateimage'}) %>;
};

Something like that, anyway...
This topic is locked and can not be replied to.