AJAX Visual effect Loading


Hi people, I made a portfolio gallery on my site
I’m happy with it except for the fact that I setup a loading gif but the
new page starts to load before its ready, so the image inside the page
loads in front of the users eyes.

I would really appreciate some help on this.

The way I have set it up is by using a link_to_remote function like so

<%= link_to_remote(image_tag("clubice_tb.jpg"),
				{:update => 'imagediv',
				:url => { :action => :clubice_window },
				:loading => "Element.show('search-indicator')",
				:complete => "Element.hide('search-indicator'), new 

Effect.toggle(‘imagediv’, ‘blind’)"},
{ :href => “…/images/clubice.jpg” })

And the action :clubice_window is a view which contains this code

<% cache do %>
<%= image_tag(“clubice.jpg”)%>
<% end %>

<%= link_to_function “Close window”, “new Effect.toggle(‘imagediv’,

It would be great if anybody could point out anything obviously wrong
with this.