Best way of storing and recalling data for display?

I want to store a number of snippets of html representing messages,
and display them in response to user events.

I’m currently storing them in a javascript array at page-load time,
then display individual snippets using Element.update(). The
message array can get extra messages added to it following an ajax
call. The set up looks something like this:

…which works, but it just feels so…unpleasant. Embedding this
big javascript stringy mess in the page source, all those escape
characters… there must be a cleaner way of doing this. Any

I’m sure there was a blog posting recently about embedding stuff like
this within a .js file generated by erb (rather than the static .js
in /public/javascripts) - but I can’t find it now. Any suggestions
what that might have been?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs