I have a model like this:
@ModelAttribute("availableFonts")
public Map<String, String> getAllAvaliableFonts() {
...
}
Model is containing font name as a key and css code as a value. Now in jsp I have a javaScript code which should apply css dynamicly to preview font, which looks more/less like this:
var css = '${availableFonts.get("Arial Black")}';
jQuery('#preview').removeClass().addClass(css);
And it's working good with hardcoded map.get(). Css value is taken from HashMap which is model in my jsp.
But I need this map key as a javaScript variable like:
var key = 'Arial Black';
var css = '${availableFonts.get("' + key + '")}';
jQuery('#preview' + i).removeClass().addClass(css);
And it's not working. Is it possible to do it in javaScript ?