Ajax callback w/o model update?


#1

Is there a way to keep a controller instance variable across a
link_to_remote call?

In essence, I want the call to re-render a partial within my page with
different display parameters, but without doing another DB call. Is
there a simple way to do this?


#2

Are the variables short enough that you can serialize them and stuff
them
inside parameters in the URL? It’s ugly but functional, and requires no
back-end help. (Or turn it into a POST for longer strings.)

  • James

#3

James M. wrote:

Are the variables short enough that you can serialize them and stuff them
inside parameters in the URL? It’s ugly but functional, and requires no
back-end help. (Or turn it into a POST for longer strings.)

Nope. I’m talking a fairly hefty Foo.find(:all, :include => […])…

So there’s good reason not to want to re-execute the query just so I can
redisplay with different parameters.


#4

Mick S. wrote:

Is there a problem with storing the results of the query in a session
variable?

Not really, although I’d prefer if it didn’t persist to the database or
filesystem. I’m also concerned about making sure that it gets cleared
as soon as I leave the page…

Thinking it through a bit further, it seems that there are really only
two solutions:

  1. Store in the session, in which case, I want to get it cleared as soon
    as I leave the page.
  • Is there a callback or such that handles this?
  1. Create a data structure in JS and do the redisplay entirely on the
    client side.
  • Has anyone experience with this? Possible with RJS?

Thanks for any help.


#5

Is there a problem with storing the results of the query in a session
variable?