开发者

Play! framefork renders incorrectly arguments from a controller to a view

My controller action:

public static void showGalery() {
    ...
    render(subPhotos, size);
}

A part of my view:

<img id="mainImage" 
     src="${subPhotos.get(0).path}" 
     class="galery-main-photo" 
     onmouseover="toolTip(${subPhotos.get(0).description});"
     onmouseout="toolTip();" />

Path passed correcly from an action, but description incorrectly (javascript function doesn't call). If I write ${subPhotos.get(0).d开发者_如何转开发escription.length()} then Javascript function are called and passed a correct length of a string. From DB got a correct description.

Thanks, Sergey


Because the description is a string, you must surround it with quotes. Be sure to use single quotes, because the HTML attribute is using double quotes.

onmouseover="toolTip('${subPhotos.get(0).description}');"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜