I have a form on my website (based on Drupal),
and I've added a JS to it, now I have some messages like
Hints on input keydown.
I was wondering, where should I keep those messages
(since I don't want them to be stored in each individual JS file
that I'll be making from now on - but in one central place)
views:
26answers:
1
A:
What about creating a js file for that effect, using a map to identify the strings?
var strings = { "SaveAsHint": "Will save the project with a different name",
"OpenHint": "Opens a new project",
"...": "Keep on going"
}
Then you include this file and reference strings["SaveAsHint"]
in your code.
Another alternative would be to store them in a database and use a callback to return this structure from the server (or, if you can afford it, use the local browser database in HTML5, filling it up once at application startup)
Vinko Vrsalovic
2010-06-27 05:38:37