Hi again. this is how I solved it:
-- helper code:
# support for client side cached requests
def include_cache_request_script
%Q{<script> function cached_request(remote_func, update) {
if($(update).innerHTML == "") { remote_func(); }
else { Element.toggle(update); }
} </script>}
end
def cached_link_to_remote(title, options)
func = "cached_request(function() {#{remote_function(options)};},
'#{options[:update]}')"
link_to_function title, func
end
-- view code:
<%= include_cache_request_script %>
...
...
<%= cached_link_to_remote title, :update => doc_id,
:url => {:action => 'foo', :id =>
item_id } %>
What do you think about it? Have a nice day,
T
Tobias Numiranta wrote:
> Hi. new prototype rails user says:
>
> Is there any convenient way to cache results on the client-side? I have
> some code with a file browser, where expanding a folder performs a
> ajax-call. It would be nice, when collapsing the tree to store the
> expanded result somehow.
>
> So that the result from calling something like this,
>
> <%= link_to_remote anode.title, :update => "node_li#{anode.id}",
> :url => {:action => "atree", :id => anode.id} %>
>
> can be reused without a http-request the second time.
>
> Have a nice day,
> T
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---